From 881a7cd68d11dffa7db1957159574c8830603628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Banno-Cloutier?= <leo.banno-cloutier@savoirfairelinux.com> Date: Tue, 1 Aug 2023 11:20:14 -0400 Subject: [PATCH] jams-react-client: remove unused translation keys and fix few capitalization errors Change-Id: I367d679a67ebe494b287e99862581d80ec31150a --- jams-react-client/i18next-scanner.config.js | 72 +++++++++---------- .../public/locales/en/translation.json | 15 ++-- .../public/locales/fr/translation.json | 11 +-- .../CustomUiPreview/CustomUiPreview.js | 2 +- .../Blueprint/EditBlueprintConfiguration.js | 2 +- .../views/Blueprint/EditBlueprintUiForm.js | 12 ++-- .../src/views/Contacts/Contacts.js | 8 ++- .../src/views/UserProfile/UserProfile.js | 2 +- 8 files changed, 59 insertions(+), 65 deletions(-) diff --git a/jams-react-client/i18next-scanner.config.js b/jams-react-client/i18next-scanner.config.js index 7b25a16c..3752e01b 100644 --- a/jams-react-client/i18next-scanner.config.js +++ b/jams-react-client/i18next-scanner.config.js @@ -1,94 +1,86 @@ const fs = require("fs"); - const path = require("path"); - const typescript = require("typescript"); module.exports = { - input: ["src/**/*.{ts}", "src/**/*/*.{js,ts,html}", "src/*.{js,ts,html}"], - + input: ["src/**/*.{js,jsx,ts,tsx,html}", "!src/**/*.d.ts"], output: "./", - options: { debug: true, - func: { list: ["i18next.t", "i18n.t", "this.i18n.tr"], - - extensions: [".js"], + extensions: [".js", ".jsx", ".ts", ".tsx"], }, - lngs: ["en", "fr"], - ns: ["translation"], - defaultLng: "en", - defaultNs: "translation", - defaultValue: "__STRING_NOT_TRANSLATED__", - resource: { loadPath: "public/locales/{{lng}}/{{ns}}.json", - savePath: "public/locales/{{lng}}/{{ns}}.json", - jsonIndent: 4, - lineEnding: "\n", }, - nsSeparator: false, // namespace separator - keySeparator: false, // key separator - interpolation: { prefix: "{{", - suffix: "}}", }, - removeUnusedKeys: true, }, transform: function customTransform(file, enc, done) { - const { ext } = path.parse(file.path); - + "use strict"; + const parser = this.parser; + const { base, ext } = path.parse(file.path); const content = fs.readFileSync(file.path, enc); - if (ext === ".ts") { + if (ext === ".ts" || ext === ".tsx") { const { outputText } = typescript.transpileModule(content.toString(), { compilerOptions: { target: "es2018", }, - - fileName: path.basename(file.path), + fileName: base, }); - this.parser.parseFuncFromString(outputText, { - list: ["i18next.t", "i18next.tr", "this.i18n.tr"], - }); + let count = 0; + + parser.parseFuncFromString( + outputText, + { list: ["i18next.t", "i18next.tr", "this.i18n.tr"] }, + (key, options) => { + parser.set( + key, + Object.assign({}, options, { + nsSeparator: false, + keySeparator: false, + }) + ); + ++count; + } + ); + + if (count > 0) { + const c = count.toString().padStart(3, " "); + const f = JSON.stringify(file.relative); + console.log(`i18next-scanner: count=${c}, file=${f}`); + } } else if (ext === ".html") { this.parser.parseAttrFromString(content, { list: ["data-i18n", "data-t", "t", "i18n"], }); // We extra behaviours `${ 'myKey' | t }` and `${ 'myKey' & t }` from the file. - const extractBehaviours = /\${ *'([a-zA-Z0-9]+)' *[&|] *t *}/g; - const strContent = content.toString(); - let group; - - while (true) { - group = extractBehaviours.exec(strContent); - - if (group === null) { - break; - } + let group = extractBehaviours.exec(strContent); + while (group !== null) { this.parser.set(group[1]); + group = extractBehaviours.exec(strContent); } } diff --git a/jams-react-client/public/locales/en/translation.json b/jams-react-client/public/locales/en/translation.json index b7d61ca3..b40481b8 100644 --- a/jams-react-client/public/locales/en/translation.json +++ b/jams-react-client/public/locales/en/translation.json @@ -3,7 +3,7 @@ "password": "Password", "confirm_password": "Confirm password", "continue": "Continue", - "users": "users", + "users": "Users", "groups": "Groups", "blueprints": "Blueprints", "settings": "Settings", @@ -116,10 +116,8 @@ "error_while_attempting_update_jams": "Error occurred while attempting to update JAMS:", "permissions": "Permissions", "configuration": "Configuration", - "updated_blueprint_configuration_successfully": "Blueprint configuration successfully updated.", - "error_updating_blueprint_configuration": "Error occurred while updating blueprint configuration.", "enable_upnp": "Enable UPnP", - "use_jami_default_turn_configuration": "Use Jami default TURN configuration", + "use_jami_default_turn_configuration": "Use default TURN configuration", "use_a_custom_turn_configuration": "Use a custom TURN configuration", "turn_server_address": "TURN Server address", "turn_server_username": "TURN server username", @@ -265,12 +263,15 @@ "welcome_has_BackgroundCustom": "Background", "instruction_background": "Choose a background color or a background image", "or": "or", - "upload_an_image": "UPLOAD AN IMAGE", "welcome_has_Logo": "Logotype", "instruction_logo": "Use Jami logotype or upload a logotype", - "upload_a_logotype": "UPLOAD A LOGOTYPE", "call_parameters": "Call parameters", "preview_tip1": "Add a picture and a nickname to complete your profile", "preview_tip2": "Why should I save my account?", - "preview_tip3": "How to set shortcuts?" + "preview_tip3": "How to set shortcuts?", + "tip_box_id_color": "Tip Box and Jami ID color", + "enable_main_box": "Add a box behind the title, description and Jami ID", + "main_box_color": "Box color", + "logo_size": "Size", + "default_settings": "Default settings" } diff --git a/jams-react-client/public/locales/fr/translation.json b/jams-react-client/public/locales/fr/translation.json index 2543518e..98c8851d 100644 --- a/jams-react-client/public/locales/fr/translation.json +++ b/jams-react-client/public/locales/fr/translation.json @@ -116,8 +116,6 @@ "error_while_attempting_update_jams": "Une erreur s'est produite lors de la tentative de mise à jour du JAMS.", "permissions": "Permissions", "configuration": "Configuration", - "updated_blueprint_configuration_successfully": "Le gabarit a été mis à jour.", - "error_updating_blueprint_configuration": "Une erreur s'est produite lors de la tentative de mise à jour du gabarit.", "enable_upnp": "Activer UPnP", "use_jami_default_turn_configuration": "Utiliser la configuration TURN par défaut proposé par Jami.", "use_a_custom_turn_configuration": "Utiliser une configuration TURN personnalisée.", @@ -265,12 +263,15 @@ "welcome_has_BackgroundCustom": "Background", "instruction_background": "Choose a background color or a background image", "or": "or", - "upload_an_image": "UPLOAD AN IMAGE", "welcome_has_Logo": "Logotype", "instruction_logo": "Use Jami logotype or upload a logotype", - "upload_a_logotype": "UPLOAD A LOGOTYPE", "call_parameters": "Call parameters", "preview_tip1": "Add a picture and a nickname to complete your profile", "preview_tip2": "Why should I save my account?", - "preview_tip3": "How to set shortcuts?" + "preview_tip3": "How to set shortcuts?", + "tip_box_id_color": "Tip Box's and Jami ID color", + "enable_main_box": "Add a box behind the title, description and the Jami ID", + "main_box_color": "Box color", + "logo_size": "Size", + "default_settings": "Default Settings" } diff --git a/jams-react-client/src/components/CustomUiPreview/CustomUiPreview.js b/jams-react-client/src/components/CustomUiPreview/CustomUiPreview.js index 054233eb..cc339aa2 100644 --- a/jams-react-client/src/components/CustomUiPreview/CustomUiPreview.js +++ b/jams-react-client/src/components/CustomUiPreview/CustomUiPreview.js @@ -130,7 +130,7 @@ export default function CustomUiPreview({ if (!description) { description = i18next.t( "welcome_Description", - "Here is your Jami identifier, don’t hesitate to share it in order to be contacted more easily!" + "Here is your Jami identifier, don't hesitate to share it in order to be contacted more easily!" ); } if (logoUrl) { diff --git a/jams-react-client/src/views/Blueprint/EditBlueprintConfiguration.js b/jams-react-client/src/views/Blueprint/EditBlueprintConfiguration.js index 9aa2b6f7..f6e5d50e 100644 --- a/jams-react-client/src/views/Blueprint/EditBlueprintConfiguration.js +++ b/jams-react-client/src/views/Blueprint/EditBlueprintConfiguration.js @@ -257,7 +257,7 @@ export default function EditBlueprintConfiguration(props) { control={<StyledRadio />} label={i18next.t( "use_jami_default_turn_configuration", - "Use Jami default TURN configuration" + "Use default TURN configuration" )} /> <FormControlLabel diff --git a/jams-react-client/src/views/Blueprint/EditBlueprintUiForm.js b/jams-react-client/src/views/Blueprint/EditBlueprintUiForm.js index 400d8405..524a7db5 100644 --- a/jams-react-client/src/views/Blueprint/EditBlueprintUiForm.js +++ b/jams-react-client/src/views/Blueprint/EditBlueprintUiForm.js @@ -119,7 +119,7 @@ const DescriptionForm = ({ uiCustomization, handleUpdateUi }) => { id="description" placeholder={i18next.t( "welcome_Description", - "Here is your Jami identifier, don’t hesitate to share it in order to be contacted more easily!" + "Here is your Jami identifier, don't hesitate to share it in order to be contacted more easily!" )} value={uiCustomization.description} onChange={(e) => { @@ -149,7 +149,7 @@ const HasTipsForm = ({ uiCustomization, handleUpdateUi }) => { name="hasTips" /> } - label={i18next.t("welcome_has_Tips", "Tips")} + label={i18next.t("welcome_has_Tips", "Enable Tips display")} /> </FormGroup> ); @@ -241,9 +241,7 @@ const CustomBackgroundForm = ({ const TipBoxAndIdColorForm = ({ uiCustomization, handleUpdateUi }) => { return ( <> - <span> - {i18next.t("tip_box_id_color", "Tip Box's and Jami ID color")} - </span> + <span>{i18next.t("tip_box_id_color", "Tip Box and Jami ID color")}</span> <ColorPickerPopup hasAlphaChannel color={uiCustomization.tipBoxAndIdColor} @@ -272,7 +270,7 @@ const MainBoxColorForm = ({ uiCustomization, handleUpdateUi }) => { } label={i18next.t( "enable_main_box", - "Add a box behind the title, description and the Jami ID" + "Add a box behind the title, description and Jami ID" )} /> </FormGroup> @@ -476,7 +474,7 @@ const EditBlueprintUiForm = ({ }); }} > - {i18next.t("default_settings", "Default Settings").toUpperCase()} + {i18next.t("default_settings", "Default settings").toUpperCase()} </Button> </> )} diff --git a/jams-react-client/src/views/Contacts/Contacts.js b/jams-react-client/src/views/Contacts/Contacts.js index 6981934a..9e11c61a 100644 --- a/jams-react-client/src/views/Contacts/Contacts.js +++ b/jams-react-client/src/views/Contacts/Contacts.js @@ -327,8 +327,10 @@ export default function Users(props) { "are_you_sure_you_want_to_remove", "Are you sure you want to remove" )} - <strong>{removedContactName}</strong> {i18next.t("from", "from")}{" "} - {props.username} {i18next.t("contacts", "contacts")} ? + <strong>{" " + removedContactName + " "}</strong> + {i18next.t("from", "from")} + {" " + props.username + " "} + {i18next.t("contacts", "contacts")}? </DialogContentText> </DialogContent> <DialogActions> @@ -485,7 +487,7 @@ export default function Users(props) { </CardBody> <CardFooter> <IconButton - color="secondary" + color="primary" onClick={() => { handleRemoveContact(contact.uri, contact.username); }} diff --git a/jams-react-client/src/views/UserProfile/UserProfile.js b/jams-react-client/src/views/UserProfile/UserProfile.js index 454ad459..08629f9f 100755 --- a/jams-react-client/src/views/UserProfile/UserProfile.js +++ b/jams-react-client/src/views/UserProfile/UserProfile.js @@ -87,7 +87,7 @@ export default function UserProfile(props) { {...a11yProps(value, 1)} /> <Tab - label={i18next.t("contacts", "Contacts")} + label={i18next.t("contacts", "contacts")} {...a11yProps(value, 2)} /> </Tabs> -- GitLab