From 4d9396cdbcc7cedfad652d221dbe00f844a2d792 Mon Sep 17 00:00:00 2001 From: gabriel-logan Date: Tue, 28 May 2024 19:30:07 -0300 Subject: [PATCH] chore: complete all texts pass to json en.json file --- .../js/functions/validatePhoneNumber/page.tsx | 36 +++++----- .../js/functions/validateSurname/page.tsx | 44 ++++++------ .../js/functions/validateTextarea/page.tsx | 67 +++++++++++-------- .../functions/validateUSPhoneNumber/page.tsx | 47 +++++++------ .../js/functions/validateUsername/page.tsx | 58 +++++++++------- docs/src/locales/en/en.json | 32 ++++++++- 6 files changed, 172 insertions(+), 112 deletions(-) diff --git a/docs/src/app/(doc-session)/documentation/js/functions/validatePhoneNumber/page.tsx b/docs/src/app/(doc-session)/documentation/js/functions/validatePhoneNumber/page.tsx index ce1e562..6f3f746 100644 --- a/docs/src/app/(doc-session)/documentation/js/functions/validatePhoneNumber/page.tsx +++ b/docs/src/app/(doc-session)/documentation/js/functions/validatePhoneNumber/page.tsx @@ -4,8 +4,12 @@ import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; import DrawerComponent from "@/components/Drawer"; +import translation from "@/components/Internationalization"; export default function ValidatePhoneNumber() { + const t = (text: string) => + translation({ text, subject: "DocumentationJsFunctions" }); + return (
@@ -13,19 +17,16 @@ export default function ValidatePhoneNumber() {

- Phone Number Validation Function Documentation + Phone Number Validation {t("Function Documentation")}

- The validatePhoneNumber function is used to validate - phone numbers. It returns an object with two properties: - 'isValid' (boolean) and 'errorMsg' (string). The - 'isValid' property will be true if the phone number meets - the specified criteria, and 'errorMsg' will contain the - error message if the phone number is invalid, or it will be null if - the phone number is valid. + {t("The")} validatePhoneNumber{" "} + {t( + 'Function is used to validate phone numbers. It returns an object with two properties: "isValid" (boolean) and "errorMsg" (string). The "isValid" property will be true if the phone number meets the specified criteria, and "errorMsg" will contain the error message if the phone number is invalid, or it will be null if the phone number is valid.', + )}

-

Function Signature

+

{t("Function Signature")}

{`function validatePhoneNumber( phoneNumber: string, @@ -33,20 +34,21 @@ export default function ValidatePhoneNumber() { ): { isValid: boolean, errorMsg: string | null };`} -

Parameters

+

{t("Parameters")}

  • - phoneNumber (string) - The phone number to be - validated. + phoneNumber (string) -{" "} + {t("The phone number to be validated.")}
  • - errorMsg (string[]) [optional] - An array of error - messages to customize the response. If not provided, the function - will use default error messages. + errorMsg (string[]) {t("[optional]")} -{" "} + {t( + "An array of error messages to customize the response. If not provided, the function will use default error messages.", + )}
-

Default Error Messages

+

{t("Default Error Messages")}

{`[ 'Invalid value passed', @@ -55,7 +57,7 @@ export default function ValidatePhoneNumber() { ]`} -

Examples

+

{t("Examples")}

{`const result1 = validatePhoneNumber('555-123-4567'); diff --git a/docs/src/app/(doc-session)/documentation/js/functions/validateSurname/page.tsx b/docs/src/app/(doc-session)/documentation/js/functions/validateSurname/page.tsx index 45d2f2c..e149ee1 100644 --- a/docs/src/app/(doc-session)/documentation/js/functions/validateSurname/page.tsx +++ b/docs/src/app/(doc-session)/documentation/js/functions/validateSurname/page.tsx @@ -4,26 +4,29 @@ import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; import DrawerComponent from "@/components/Drawer"; +import translation from "@/components/Internationalization"; export default function ValidateSurname() { + const t = (text: string) => + translation({ text, subject: "DocumentationJsFunctions" }); + return (
-

Surname Validation Function Documentation

+

+ Surname Validation {t("Function Documentation")} +

- The validateSurname function is used to validate - surnames. It returns an object with two properties: - 'isValid' (boolean) and 'errorMsg' (string). The - 'isValid' property will be true if the surname meets the - specified criteria, and 'errorMsg' will contain the error - message if the surname is invalid, or it will be null if the surname - is valid. + {t("The")} validateSurname{" "} + {t( + "function is used to validate surnames. It returns an object with two properties: 'isValid' (boolean) and 'errorMsg' (string). The 'isValid' property will be true if the surname meets the specified criteria, and 'errorMsg' will contain the error message if the surname is invalid, or it will be null if the surname is valid.", + )}

-

Function Signature

+

{t("Function Signature")}

{`function validateSurname( surname: string, @@ -35,27 +38,28 @@ export default function ValidateSurname() { ): { isValid: boolean, errorMsg: string | null };`} -

Parameters

+

{t("Parameters")}

  • - surname (string) - The surname to be validated. + surname (string) - {t("The surname to be validated.")}
  • - minLength (number) [optional] - The minimum length of - the surname. Default is 1. + minLength (number) {t("[optional]")} -{" "} + {t("The minimum length of the surname. Default is 1.")}
  • - maxLength (number) [optional] - The maximum length of - the surname. Default is 25. + maxLength (number) {t("[optional]")} -{" "} + {t("The maximum length of the surname. Default is 25.")}
  • - errorMsg (string[]) [optional] - An array of error - messages to customize the response. If not provided, the function - will use default error messages. + errorMsg (string[]) {t("[optional]")} -{" "} + {t( + "An array of error messages to customize the response. If not provided, the function will use default error messages.", + )}
-

Default Error Messages

+

{t("Default Error Messages")}

{`[ 'Invalid value passed', @@ -67,7 +71,7 @@ export default function ValidateSurname() { ]`} -

Examples

+

{t("Examples")}

{`const result1 = validateSurname("Jackson", { minLength: 3, diff --git a/docs/src/app/(doc-session)/documentation/js/functions/validateTextarea/page.tsx b/docs/src/app/(doc-session)/documentation/js/functions/validateTextarea/page.tsx index 2e90ade..5fd11ee 100644 --- a/docs/src/app/(doc-session)/documentation/js/functions/validateTextarea/page.tsx +++ b/docs/src/app/(doc-session)/documentation/js/functions/validateTextarea/page.tsx @@ -4,21 +4,26 @@ import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; import DrawerComponent from "@/components/Drawer"; +import translation from "@/components/Internationalization"; export default function ValidateTextarea() { + const t = (text: string) => + translation({ text, subject: "DocumentationJsFunctions" }); + return (
-

validateTextarea Function

+

validateTextarea {t("Function Documentation")}

- This function is a text area validation utility that checks the - validity of a given textarea string based on certain criteria. + {t( + "This function is a text area validation utility that checks the validity of a given textarea string based on certain criteria.", + )}

-

Function Signature

+

{t("Function Signature")}

{`/** @@ -36,51 +41,54 @@ export default function ValidateTextarea() { */`} -

Parameters

+

{t("Parameters")}

  • - textarea (string): The input textarea string to be - validated. + textarea (string):{" "} + {t("The input textarea string to be validated.")}
  • - isRequired (boolean, optional, default: false): A - flag to determine if the textarea is required. + isRequired (boolean, optional, default: false):{" "} + {t("A flag to determine if the textarea is required.")}
  • - maxLength (number, optional, default: 50): The - maximum allowed length for the textarea. + maxLength (number, optional, default: 50):{" "} + {t("The maximum allowed length for the textarea.")}
  • errorMsg (string array, optional, default: - predefined messages): An array of custom error messages for - different validation conditions. The array should contain three - elements corresponding to different error scenarios. If not - provided, default error messages will be used. Default Error - Messages: + predefined messages):{" "} + {t( + "An array of custom error messages for different validation conditions. The array should contain three elements corresponding to different error scenarios. If not provided, default error messages will be used. Default Error Messages:", + )}
      -
    • Index 0: 'This textarea is too big'
    • -
    • Index 1: 'Can not be empty'
    • -
    • Index 2: 'Unknown error'
    • +
    • {t('Index 0: "This textarea is too big"')}
    • +
    • {t('Index 1: "Can not be empty"')}
    • +
    • {t('Index 2: "Unknown error"')}
-

Return Value

+

{t("Return Value")}

- The function returns an object with two properties: + {t("The function returns an object with two properties:")}

  • - isValid (boolean): Indicates if the textarea is - valid based on the given criteria. + isValid (boolean):{" "} + {t( + "Indicates if the textarea is valid based on the given criteria.", + )}
  • - errorMsg (string): Contains the corresponding - error message, if any, based on the validation result. + errorMsg (string):{" "} + {t( + "Contains the corresponding error message, if any, based on the validation result.", + )}

-

Usage Examples

+

{t("Usage Examples")}

{`validateTextarea("Some text content"); // Example 1 @@ -94,9 +102,10 @@ validateTextarea("Very long text...", { isRequired: false, maxLength: 10 }); //

- Note: The examples provided demonstrate how to use - the function with different parameters and show the expected return - values. + {t("Note:")}{" "} + {t( + "The examples provided demonstrate how to use the function with different parameters and show the expected return values.", + )}

diff --git a/docs/src/app/(doc-session)/documentation/js/functions/validateUSPhoneNumber/page.tsx b/docs/src/app/(doc-session)/documentation/js/functions/validateUSPhoneNumber/page.tsx index 8b66e0e..f277160 100644 --- a/docs/src/app/(doc-session)/documentation/js/functions/validateUSPhoneNumber/page.tsx +++ b/docs/src/app/(doc-session)/documentation/js/functions/validateUSPhoneNumber/page.tsx @@ -4,8 +4,12 @@ import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; import DrawerComponent from "@/components/Drawer"; +import translation from "@/components/Internationalization"; export default function validateUSPhoneNumber() { + const t = (text: string) => + translation({ text, subject: "DocumentationJsFunctions" }); + return (
@@ -13,24 +17,20 @@ export default function validateUSPhoneNumber() {

- US Phone Number Validation Function Documentation + US Phone Number Validation {t("Function Documentation")}

- The validateUSPhoneNumber function is used to validate US - phone numbers. It supports various formats, including - "XXX-XXX-XXXX", "(XXX) XXX-XXXX", and "1 - (XXX) XXX-XXXX". It returns an object with two properties: - "isValid" (boolean) and "errorMsg" (string). The - "isValid" property will be true if the phone number is - valid, and "errorMsg" will contain the error message if the - phone number is invalid, or it will be null if the phone number is - valid. + {t("The")} validateUSPhoneNumber{" "} + {t( + 'function is used to validate US phone numbers. It supports various formats, including "XXX-XXX-XXXX", "(XXX) XXX-XXXX", and "1 (XXX) XXX-XXXX". It returns an object with two properties: "isValid" (boolean) and "errorMsg" (string). The "isValid" property will be true if the phone number is valid, and "errorMsg" will contain the error message if the phone number is invalid, or it will be null if the phone number is valid.', + )}

Import

- The function can be imported using ES6 syntax from the - "multiform-validator" package: + {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )}

@@ -38,7 +38,9 @@ export default function validateUSPhoneNumber() {

- Alternatively, you can import the function using CommonJS syntax with{" "} + {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} require (Node.js):

@@ -46,7 +48,7 @@ export default function validateUSPhoneNumber() { {`const { validateUSPhoneNumber } = require('multiform-validator');`} -

Function Signature

+

{t("Function Signature")}

{`function validateUSPhoneNumber( @@ -55,20 +57,21 @@ export default function validateUSPhoneNumber() { ): { isValid: boolean, errorMsg: string | null };`} -

Parameters

+

{t("Parameters")}

  • - phoneNumber (string) - The US phone number to be - validated. + phoneNumber (string) -{" "} + {t("The US phone number to be validated.")}
  • - errorMsg (string[]) [optional] - An array of error - messages to customize the response. If not provided, the function - will use default error messages. + errorMsg (string[]){" "} + {t( + "[optional] - An array of error messages to customize the response. If not provided, the function will use default error messages.", + )}
-

Default Error Messages

+

{t("Default Error Messages")}

{`[ @@ -78,7 +81,7 @@ export default function validateUSPhoneNumber() { ]`} -

Examples

+

{t("Examples")}

{`const result1 = validateUSPhoneNumber('555-123-4567'); diff --git a/docs/src/app/(doc-session)/documentation/js/functions/validateUsername/page.tsx b/docs/src/app/(doc-session)/documentation/js/functions/validateUsername/page.tsx index 7e7edf0..aff1bca 100644 --- a/docs/src/app/(doc-session)/documentation/js/functions/validateUsername/page.tsx +++ b/docs/src/app/(doc-session)/documentation/js/functions/validateUsername/page.tsx @@ -4,29 +4,33 @@ import { Prism as SyntaxHighlighter } from "react-syntax-highlighter"; import { a11yDark } from "react-syntax-highlighter/dist/esm/styles/prism"; import DrawerComponent from "@/components/Drawer"; +import translation from "@/components/Internationalization"; export default function ValidateUsername() { + const t = (text: string) => + translation({ text, subject: "DocumentationJsFunctions" }); + return (
-

Username Validation Function Documentation

+

+ Username Validation {t("Function Documentation")} +

- The validateUsername function is used to validate - usernames. It returns an object with two properties: - "isValid" (boolean) and "errorMsg" (string). The - "isValid" property will be true if the username meets the - specified criteria, and "errorMsg" will contain the error - message if the username is invalid, or it will be null if the username - is valid. + {t("The")} validateUsername{" "} + {t( + 'function is used to validate usernames. It returns an object with two properties: "isValid" (boolean) and "errorMsg" (string). The "isValid" property will be true if the username meets the specified criteria, and "errorMsg" will contain the error message if the username is invalid, or it will be null if the username is valid.', + )}

Import

- The function can be imported using ES6 syntax from the - "multiform-validator" package: + {t( + 'The function can be imported using ES6 syntax from the "multiform-validator" package:', + )}

@@ -34,7 +38,9 @@ export default function ValidateUsername() {

- Alternatively, you can import the function using CommonJS syntax with{" "} + {t( + "Alternatively, you can import the function using CommonJS syntax with", + )}{" "} require (Node.js):

@@ -42,7 +48,7 @@ export default function ValidateUsername() { {`const {validateUsername} = require('multiform-validator');`} -

Function Signature

+

{t("Function Signature")}

{`interface OptionsParams { @@ -63,27 +69,33 @@ function validateUsername( ): { isValid: boolean, errorMsg: string | null };`} -

Parameters

+

{t("Parameters")}

  • - username (string) - The username to be validated. + username (string) -{" "} + {t("The username to be validated.")}
  • - minLength (number) [optional] - The minimum length of - the username. Default is 1. + minLength (number){" "} + {t( + "[optional] - The minimum length of the username. Default is 1.", + )}
  • - maxLength (number) [optional] - The maximum length of - the username. Default is Infinity. + maxLength (number){" "} + {t( + "[optional] - The maximum length of the username. Default is Infinity.", + )}
  • - errorMsg (string[]) [optional] - An array of error - messages to customize the response. If not provided, the function - will use default error messages. + errorMsg (string[]){" "} + {t( + "[optional] - An array of error messages to customize the response. If not provided, the function will use default error messages.", + )}
-

Default Error Messages

+

{t("Default Error Messages")}

{`[ @@ -97,7 +109,7 @@ function validateUsername( ]`} -

Examples

+

{t("Examples")}

{`const result1 = validateUsername("User999", { diff --git a/docs/src/locales/en/en.json b/docs/src/locales/en/en.json index 623f0bb..b8aa80b 100644 --- a/docs/src/locales/en/en.json +++ b/docs/src/locales/en/en.json @@ -364,6 +364,36 @@ "Whether the password requires at least one special character": "Whether the password requires at least one special character", "Default value: false.": "Default value: false.", "Whether the password requires at least one number. Default value: false.": "Whether the password requires at least one number. Default value: false.", - "Whether the password requires at least one letter. Default value: false.": "Whether the password requires at least one letter. Default value: false." + "Whether the password requires at least one letter. Default value: false.": "Whether the password requires at least one letter. Default value: false.", + + "Function is used to validate phone numbers. It returns an object with two properties: \"isValid\" (boolean) and \"errorMsg\" (string). The \"isValid\" property will be true if the phone number meets the specified criteria, and \"errorMsg\" will contain the error message if the phone number is invalid, or it will be null if the phone number is valid.": "Function is used to validate phone numbers. It returns an object with two properties: \"isValid\" (boolean) and \"errorMsg\" (string). The \"isValid\" property will be true if the phone number meets the specified criteria, and \"errorMsg\" will contain the error message if the phone number is invalid, or it will be null if the phone number is valid.", + "The phone number to be validated.": "The phone number to be validated.", + "An array of error messages to customize the response. If not provided, the function will use default error messages.": "An array of error messages to customize the response. If not provided, the function will use default error messages.", + + "function is used to validate surnames. It returns an object with two properties: 'isValid' (boolean) and 'errorMsg' (string). The 'isValid' property will be true if the surname meets the specified criteria, and 'errorMsg' will contain the error message if the surname is invalid, or it will be null if the surname is valid.": "function is used to validate surnames. It returns an object with two properties: 'isValid' (boolean) and 'errorMsg' (string). The 'isValid' property will be true if the surname meets the specified criteria, and 'errorMsg' will contain the error message if the surname is invalid, or it will be null if the surname is valid.", + "The surname to be validated.": "The surname to be validated.", + "The minimum length of the surname. Default is 1.": "The minimum length of the surname. Default is 1.", + "The maximum length of the surname. Default is 25.": "The maximum length of the surname. Default is 25.", + + "The input textarea string to be validated.": "The input textarea string to be validated.", + "A flag to determine if the textarea is required.": "A flag to determine if the textarea is required.", + "The maximum allowed length for the textarea.": "The maximum allowed length for the textarea.", + "An array of custom error messages for different validation conditions. The array should contain three elements corresponding to different error scenarios. If not provided, default error messages will be used. Default Error Messages:": "An array of custom error messages for different validation conditions. The array should contain three elements corresponding to different error scenarios. If not provided, default error messages will be used. Default Error Messages:", + "Index 0: \"This textarea is too big\"": "Index 0: \"This textarea is too big\"", + "Index 1: \"Can not be empty\"": "Index 1: \"Can not be empty\"", + "Index 2: \"Unknown error\"": "Index 2: \"Unknown error\"", + "Return Value": "Return Value", + "The function returns an object with two properties:": "The function returns an object with two properties:", + "Indicates if the textarea is valid based on the given criteria.": "Indicates if the textarea is valid based on the given criteria.", + "Contains the corresponding error message, if any, based on the validation result.": "Contains the corresponding error message, if any, based on the validation result.", + "This function is a text area validation utility that checks the validity of a given textarea string based on certain criteria.": "This function is a text area validation utility that checks the validity of a given textarea string based on certain criteria.", + + "The function is a text area validation utility that checks the validity of a given textarea string based on certain criteria.": "The function is a text area validation utility that checks the validity of a given textarea string based on certain criteria.", + "The username to be validated.": "The username to be validated.", + "[optional] - The minimum length of the username. Default is 1.": "[optional] - The minimum length of the username. Default is 1.", + "[optional] - The maximum length of the username. Default is Infinity.": "[optional] - The maximum length of the username. Default is Infinity.", + + "function is used to validate US phone numbers. It supports various formats, including \"XXX-XXX-XXXX\", \"(XXX) XXX-XXXX\", and \"1 (XXX) XXX-XXXX\". It returns an object with two properties: \"isValid\" (boolean) and \"errorMsg\" (string). The \"isValid\" property will be true if the phone number is valid, and \"errorMsg\" will contain the error message if the phone number is invalid, or it will be null if the phone number is valid.": "function is used to validate US phone numbers. It supports various formats, including \"XXX-XXX-XXXX\", \"(XXX) XXX-XXXX\", and \"1 (XXX) XXX-XXXX\". It returns an object with two properties: \"isValid\" (boolean) and \"errorMsg\" (string). The \"isValid\" property will be true if the phone number is valid, and \"errorMsg\" will contain the error message if the phone number is invalid, or it will be null if the phone number is valid.", + "The US phone number to be validated.": "The US phone number to be validated." } }