Open ARZarkesh opened 2 years ago
Here is how I currently do it, begin with installing `i18next-scanner’ and then add the following config:
/** RUN WITH COMMAND: i18next-scanner **/
const fs = require('fs')
const chalk = require('chalk')
const input = [
'src/modules/*.{htm,html,js,jsx,vue,ts}',
'src/router/*.{htm,html,js,jsx,vue,ts}',
'src/constants/*.{htm,html,js,jsx,vue,ts}',
'src/composables/*.{htm,html,js,jsx,vue,ts}',
'src/components/*.{htm,html,js,jsx,vue,ts}',
'src/components/*/*.{htm,html,js,jsx,vue,ts}',
'src/components/*/*/*.{htm,html,js,jsx,vue,ts}',
'src/components/*/*/*/*.{htm,html,js,jsx,vue,ts}',
'src/utils/*.{htm,html,js,jsx,vue,ts}',
'!app/**/*.spec.{js,jsx}',
'!app/i18n/**',
'!**/node_modules/**',
]
module.exports = {
input,
output: './',
options: {
debug: true,
func: {
list: ['t'],
extensions: ['.js', '.jsx', '.vue', '.html', '.htm', '.ts'],
},
trans: {
component: 'Trans',
extensions: [],
},
lngs: ['prx'],
ns: ['locale'],
defaultLng: 'en',
defaultNs: 'locale',
defaultValue: '__STRING_NOT_TRANSLATED__',
resource: {
loadPath: 'locales/{lng}.json',
savePath: 'locales/{lng}.json',
jsonIndent: 4,
lineEnding: '\n',
},
nsSeparator: false,
keySeparator: '.',
interpolation: {
prefix: '{',
suffix: '}',
}
}
}
I added lngs: [prx], (where prx is just short for proxy). When I run i18next-scanner, all unused keys are added to prx.json and then I can add them to the languages I want translated directly in VS Code with i18n ally. If anyone has improvements I'd be happy to hear it. :)
Is your feature related to a specific framework or general for this extension
vue-i18n
Is your feature request related to a problem? Please describe.
-
Describe the solution you'd like
-
Additional context
I want this ability to find and remove unused keys to decrease locale files sizes.