feat: prevent translation keys which don't exist in locale files

This commit is contained in:
Tom French 2022-08-30 11:12:19 +01:00
parent 43740f18f1
commit 5c56370920
6 changed files with 849 additions and 40 deletions

18
.github/workflows/i18n.yml vendored Normal file
View file

@ -0,0 +1,18 @@
name: i18n
on:
push:
branches:
- master
pull_request:
branches: '*'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up environment
uses: ./.github/actions/setup
- name: Check i18n keys
run: yarn workspace desktop-client check-i18n --fail-on-update

View file

@ -0,0 +1,16 @@
module.exports = {
input: ['src/**/*.js'],
output: 'src/locales/$LOCALE.json',
locales: ['en-GB', 'es-ES'],
sort: true,
indentation: 4,
// Force usage of JsxLexer for .js files as otherwise we can't pick up <Trans> components.
lexers: {
js: ['JsxLexer'],
ts: ['JsxLexer'],
jsx: ['JsxLexer'],
tsx: ['JsxLexer'],
default: ['JsxLexer']
}
};

View file

@ -43,6 +43,7 @@
"glamor": "^2.20.40",
"html-webpack-plugin": "4.0.0-alpha.2",
"i18next": "^21.9.1",
"i18next-parser": "^6.5.0",
"identity-obj-proxy": "3.0.0",
"load-js": "^3.0.3",
"mini-css-extract-plugin": "0.4.3",
@ -88,7 +89,8 @@
"watch": "cross-env PORT=3001 node scripts/start.js",
"build": "cross-env INLINE_RUNTIME_CHUNK=false node scripts/build.js",
"build:browser": "./bin/build-browser",
"lint": "eslint src"
"lint": "eslint src",
"check-i18n": "i18next"
},
"browserslist": [
"electron 3.0"

View file

@ -8,8 +8,8 @@
"needAccountMessage": "Para que Actual sea útil, debe <strong>agregar una cuenta</strong>. Puedes vincular la cuenta para descargar transacciones automáticamente o administrala localmente."
},
"bootstrap": {
"title": "Bootstrap esta instancia de Actual",
"setPassword": "Establecer una contraseña para esta instancia de servidor",
"title": "Bootstrap esta instancia de Actual",
"tryDemo": "Probar Demo"
}
}

View file

@ -21,6 +21,8 @@ i18n
// you can use the i18n.changeLanguage function to change the language manually: https://www.i18next.com/overview/api#changelanguage
// if you're using a language detector, do not define the lng option
// We enforce that a locales have all keys so we treat empty string as missing value.
returnEmptyString: false,
interpolation: {
escapeValue: false // react already safes from xss
}

847
yarn.lock

File diff suppressed because it is too large Load diff