Fix translations scripts

pull/1884/head
Johan Girod 2021-12-15 09:58:39 +01:00
parent d94b1e9680
commit d9b898aa7c
5 changed files with 58 additions and 11 deletions

View File

@ -30,10 +30,10 @@
"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"
"i18n:rules:check": "cd site && node scripts/i18n/check-missing-rule-translation.js",
"i18n:rules:translate": "cd site && node scripts/i18n/translate-rules.js",
"i18n:ui:check": " cd site && yarn run i18next -c scripts/i18n/parser.config.js && node scripts/i18n/check-missing-UI-translation",
"i18n:ui:translate": "cd site && rm -rf source/locales/static-analysis-fr.json && yarn run i18next -c scripts/i18n/parser.config.js && node scripts/i18n/translate-ui.js"
},
"resolutions": {
"@mui/styled-engine": "npm:@mui/styled-engine-sc@latest"

View File

@ -1,5 +1,7 @@
// i18next-parser.config.js
const { UiStaticAnalysisPath } = require('./utils')
module.exports = {
contextSeparator: '_',
// Key separator used in your translation keys
@ -69,7 +71,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: 'site/source/locales/static-analysis-$LOCALE.json',
output: UiStaticAnalysisPath,
// Supports $LOCALE and $NAMESPACE injection
// Supports JSON (.json) and YAML (.yml) file formats
// Where to write the locale files relative to process.cwd()

View File

@ -8,9 +8,23 @@ require('../../../modele-social/build')
let rules = require('../../../modele-social')
let { parse } = require('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 rulesTranslationPath = path.resolve(
__dirname,
'../../source/locales/rules-en.yaml'
)
let UiTranslationPath = path.resolve(
__dirname,
'../../source/locales/ui-en.yaml'
)
let UiOriginalTranslationPath = path.resolve(
__dirname,
'../../source/locales/ui-fr.yaml'
)
let UiStaticAnalysisPath = path.resolve(
__dirname,
'../../source/locales/static-analysis-fr.json'
)
let attributesToTranslate = [
'titre',
@ -93,9 +107,7 @@ function getRulesMissingTranslations() {
}
const getUiMissingTranslations = () => {
const staticKeys = require(path.resolve(
'site/source/locales/static-analysis-fr.json'
))
const staticKeys = require(UiStaticAnalysisPath)
const translatedKeys = parse(fs.readFileSync(UiTranslationPath, 'utf-8'))
const originalKeys = parse(
fs.readFileSync(UiOriginalTranslationPath, 'utf-8')
@ -141,6 +153,7 @@ module.exports = {
fetchTranslation,
getRulesMissingTranslations,
getUiMissingTranslations,
UiStaticAnalysisPath,
rulesTranslationPath,
UiTranslationPath,
UiOriginalTranslationPath,

View File

@ -1239,6 +1239,11 @@ pages:
title: Income simulator for a private medical assistant
tooltip: Nurses, masseur-physiotherapists, chiropodists, speech therapists and
orthoptists
auxiliaire-medical:
meta:
description: Calculation of the net income after contributions from the total
income.
title: "Chartered accountant: income simulator"
avocat:
shortname: Lawyer
title: Income simulator for private lawyers
@ -1246,6 +1251,10 @@ pages:
intégrer module web: <0>Integrate the web module</0><1>Add this simulator to
your website in one click</1>
chirurgien-dentiste:
meta:
description: Calculation of the net income after contributions from the total
income.
title: "Dental surgeon : income simulator"
shortname: Dental surgeon
title: Income simulator for a private dental surgeon
chômage-partiel:
@ -1476,6 +1485,10 @@ pages:
simulator.</5>
title: Corporate Tax Simulator
médecin:
meta:
description: Calculation of net income after deduction of contributions from
total revenue. Sector 1, sector 2, and excess fees taken into account
title: "Doctor: income simulator"
shortname: Doctor
title: Income simulator for private practitioners
pamc:
@ -1501,6 +1514,10 @@ pages:
shortname: Liberal profession
title: Professional Income Simulator
sage-femme:
meta:
description: Calculation of the net income after contributions from the total
income.
title: "Midwife : income simulator"
shortname: Midwife
title: Income simulator for private midwives
salarié:

View File

@ -958,10 +958,17 @@ pages:
title: Simulateur de revenus pour auxiliaire médical en libéral
tooltip: Infirmiers, masseurs-kinésithérapeutes, pédicures-podologues,
orthophonistes et orthoptistes
auxiliaire-medical:
meta:
description: Calcul du revenu net après cotisations à partir du total des recettes.
title: "Expert-comptable : simulateur de revenus"
avocat:
shortname: Avocat
title: Simulateur de revenus pour avocat en libéral
chirurgien-dentiste:
meta:
description: Calcul du revenu net après cotisations à partir du total des recettes.
title: "Chirurgien-dentiste : simulateur de revenus"
shortname: Chirurgien-dentiste
title: Simulateur de revenus pour chirurgien-dentiste en libéral
chômage-partiel:
@ -1152,6 +1159,11 @@ pages:
pas intégrés dans le simulateur.</5>
title: Simulateur d'impôt sur les sociétés
médecin:
meta:
description: Calcul du revenu net après déduction des cotisations à partir du
total des recettes. Secteur 1, secteur 2, et dépassement dhonoraire
pris en compte
title: "Médecin : simulateur de revenus"
shortname: Médecin
title: Simulateur de revenus pour médecin en libéral
pamc:
@ -1178,6 +1190,9 @@ pages:
shortname: Profession libérale
title: Simulateur de revenus pour profession libérale
sage-femme:
meta:
description: Calcul du revenu net après cotisations à partir du total des recettes.
title: "Sage-femme : simulateur de revenus"
shortname: Sage-femme
title: Simulateur de revenus pour sage-femme en libéral
salarié: