Browse Source

Env variable HIGHLIGHT_I18N=1 to highlight i18nized strings

master
Thibaut Boustany 7 years ago
parent
commit
b47bd82dc9
No known key found for this signature in database GPG Key ID: 32475B11A2B13EEC
  1. 19
      src/renderer/i18n/instanciate.js

19
src/renderer/i18n/instanciate.js

@ -9,6 +9,12 @@ const commonConfig = {
},
}
const highlightPostProcessor = {
type: 'postProcessor',
name: 'highlight',
process: value => `!!${value}!!`,
}
function addPluralRule(i18n) {
i18n.services.pluralResolver.addRule('en', {
numbers: [0, 1, 'plural'],
@ -18,10 +24,19 @@ function addPluralRule(i18n) {
}
export function createWithBackend(backend, backendOpts) {
i18n.use(backend).init({
const config = {
...commonConfig,
...backendOpts,
})
}
if (process.env.HIGHLIGHT_I18N) {
config.postProcess = 'highlight'
}
i18n
.use(backend)
.use(highlightPostProcessor)
.init(config)
return addPluralRule(i18n)
}

Loading…
Cancel
Save