diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1464f6307..82c91758f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -50,6 +50,4 @@ jobs: path: '**/node_modules' key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}-v2 - run: yarn install --frozen-lockfile - - working-directory: site - run: yarn run i18n:rules:check; - yarn run i18n:ui:check + - run: yarn run i18n:check diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7529b057f..a6cd3d3c9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -137,7 +137,7 @@ $ yarn workspace site test:dev-e2e:mycompanyinfrance Le site est disponible en français, et en anglais sur https://mycompanyinfrance.com -Les traductions se trouvent dans le répertoire `source/locales`. +Les traductions se trouvent dans le répertoire `site/source/locales`. La librairie utilisée pour la traduction de l'UI est [react-i18next](https://react.i18next.com/). @@ -150,8 +150,7 @@ Le circle-ci fait une analyse statique du code pour repérer les chaînes non traduites, dans le moteur et l'UI : ```sh -$ yarn run i18n:rules:check -$ yarn run i18n:ui:check +$ yarn run i18n:check ``` Pour traduire automatiquement les chaînes manquantes via l'api Deepl : @@ -159,6 +158,9 @@ Pour traduire automatiquement les chaînes manquantes via l'api Deepl : ```sh $ yarn run i18n:rules:translate $ yarn run i18n:ui:translate + +# ou bien pour les deux commandes d'un coup +$ yarn run i18n:translate ``` N'oubliez pas de vérifier sur le diff que rien n'est choquant. diff --git a/package.json b/package.json index 6bc2f25c5..eba2c0f01 100644 --- a/package.json +++ b/package.json @@ -120,7 +120,13 @@ "test:regressions": "yarn workspace modele-social build && jest --silent", "clean": "yarn workspaces run clean && rimraf node_modules", "start": "yarn workspace site start", - "moso:up": "yarn workspace modele-social run up && yarn workspace site upgrade modele-social" + "moso:up": "yarn workspace modele-social run up && yarn workspace site upgrade modele-social", + "i18n:check": "yarn run i18n:rules:check && yarn run i18n:ui:check", + "i18n:translate": "yarn run i18n:rules:translate && yarn run i18n:ui:translate", + "i18n:rules:check": "node site/scripts/i18n/check-missing-rule-translation.js", + "i18n:rules:translate": "node site/scripts/i18n/translate-rules.js", + "i18n:ui:check": "yarn run i18next -c site/scripts/i18n/parser.config.js && node site/scripts/i18n/check-missing-UI-translation", + "i18n:ui:translate": "rm -rf site/source/locales/static-analysis-fr.json && yarn run i18next -c site/scripts/i18n/parser.config.js && node site/scripts/i18n/translate-ui.js" }, "workspaces": [ "modele-social", diff --git a/site/package.json b/site/package.json index 8e1e7b78e..2d4639390 100644 --- a/site/package.json +++ b/site/package.json @@ -141,12 +141,6 @@ "test:dev-e2e:mon-entreprise": "cypress open --browser chromium", "test:dev-e2e:mycompanyinfrance": "cypress open --browser chromium --config baseUrl=http://localhost:8080/infrance,integrationFolder=cypress/integration/mon-entreprise/english --env language=en", "test:record-http-calls:mon-entreprise": "cypress run --env record_http=", - "i18n:check": "yarn run i18n:rules:check && yarn run i18n:ui:check", - "i18n:translate": "yarn run i18n:rules:translate && yarn run i18n:ui:translate", - "i18n:rules:check": "node scripts/i18n/check-missing-rule-translation.js", - "i18n:rules:translate": "node scripts/i18n/translate-rules.js", - "i18n:ui:check": "yarn run i18next -c scripts/i18n/parser.config.js && node scripts/i18n/check-missing-UI-translation", - "i18n:ui:translate": "rm -rf source/locales/static-analysis-fr.json && yarn run i18next -c scripts/i18n/parser.config.js && node scripts/i18n/translate-ui.js", "start": "node dev-server.js", "serve:dev": "concurrently -k \"yarn run serve:dev:mon-entreprise\" \"yarn run serve:dev:mycompanyinfrance & yarn run serve:dev:publicodes\"", "serve:dev:mon-entreprise": "PORT=5000 serve --config serve.mon-entreprise.json --no-clipboard", diff --git a/site/scripts/i18n/parser.config.js b/site/scripts/i18n/parser.config.js index 504bf25da..8eab782c0 100644 --- a/site/scripts/i18n/parser.config.js +++ b/site/scripts/i18n/parser.config.js @@ -50,7 +50,7 @@ module.exports = { // Namespace separator used in your translation keys // If you want to use plain english keys, separators such as `.` and `:` will conflict. You might want to set `keySeparator: false` and `namespaceSeparator: false`. That way, `t('Status: Loading...')` will not think that there are a namespace and three separator dots for instance. - output: 'source/locales/static-analysis-$LOCALE.json', + output: 'site/source/locales/static-analysis-$LOCALE.json', // Supports $LOCALE and $NAMESPACE injection // Supports JSON (.json) and YAML (.yml) file formats // Where to write the locale files relative to process.cwd() diff --git a/site/scripts/i18n/utils.js b/site/scripts/i18n/utils.js index 998a5831f..055e7030a 100644 --- a/site/scripts/i18n/utils.js +++ b/site/scripts/i18n/utils.js @@ -8,9 +8,9 @@ require('../../../modele-social/build') let rules = require('../../../modele-social') let { parse } = require('yaml') -let rulesTranslationPath = path.resolve('source/locales/rules-en.yaml') -let UiTranslationPath = path.resolve('source/locales/ui-en.yaml') -let UiOriginalTranslationPath = path.resolve('source/locales/ui-fr.yaml') +let rulesTranslationPath = path.resolve('site/source/locales/rules-en.yaml') +let UiTranslationPath = path.resolve('site/source/locales/ui-en.yaml') +let UiOriginalTranslationPath = path.resolve('site/source/locales/ui-fr.yaml') let attributesToTranslate = [ 'titre', @@ -94,7 +94,7 @@ function getRulesMissingTranslations() { const getUiMissingTranslations = () => { const staticKeys = require(path.resolve( - 'source/locales/static-analysis-fr.json' + 'site/source/locales/static-analysis-fr.json' )) const translatedKeys = parse(fs.readFileSync(UiTranslationPath, 'utf-8')) const originalKeys = parse( diff --git a/site/source/locales/ui-en.yaml b/site/source/locales/ui-en.yaml index 99e875cd7..21ed1eea8 100644 --- a/site/source/locales/ui-en.yaml +++ b/site/source/locales/ui-en.yaml @@ -980,10 +980,10 @@ pages: bibliothèque: "<0>Integrate our calculation library<1>If you think that your website or service would benefit from displaying salary calculations, for example switching from gross to net salary, good news: all the tax and - contribution calculations behind mycompanyinfrance are free and easily reusable - thanks to the <2>NPM publicodes library.<2>How to use this - library?<3>All our calculation rules are written in `publicodes`, a - declarative language developed by beta.gouv.fr and the Urssaf to encode + contribution calculations behind mycompanyinfrance are free and easily + reusable thanks to the <2>NPM publicodes library.<2>How to use + this library?<3>All our calculation rules are written in `publicodes`, + a declarative language developed by beta.gouv.fr and the Urssaf to encode algorithms of public interest. <2>Learn more about publicodes<4>To perform your own calculations, you must install the publicodes interpreter, download the rules used on my-company, call the evaluation @@ -1054,9 +1054,10 @@ pages: library: <0>Using the calculation engine<1>The entire socio-fiscal calculation engine developed by Urssaf, freely available in the form of an NPM library. - description: In addition to the mycompanyinfrance site, we provide free and open source - tools to integrate on your website. You can thus include the tools - created for <1>mycompanyinfrance directly in the usual paths of your users. + description: In addition to the mycompanyinfrance site, we provide free and open + source tools to integrate on your website. You can thus include the + tools created for <1>mycompanyinfrance directly in the usual paths + of your users. titre: Integrate social security law at the heart of your tools iframe: csp-1: <0>The error below that appears in the console is related to the