Skip to content

Commit 634b3c9

Browse files
committed
Fix i18n writing locale files in production
This commit should prevent the i18n module from adding missing translations to the local files in setups that are not for development. This way we keep the directory clean and idempotent. Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
1 parent 551840a commit 634b3c9

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ if (config.csp.enable) {
131131
i18n.configure({
132132
locales: ['en', 'zh', 'zh-CN', 'zh-TW', 'fr', 'de', 'ja', 'es', 'ca', 'el', 'pt', 'it', 'tr', 'ru', 'nl', 'hr', 'pl', 'uk', 'hi', 'sv', 'eo', 'da'],
133133
cookie: 'locale',
134-
directory: path.join(__dirname, '/locales')
134+
directory: path.join(__dirname, '/locales'),
135+
updateFiles: config.updateI18nFiles
135136
})
136137

137138
app.use(cookieParser())

lib/config/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ config.isSAMLEnable = config.saml.idpSsoUrl
102102
config.isOAuth2Enable = config.oauth2.clientID && config.oauth2.clientSecret
103103
config.isPDFExportEnable = config.allowPDFExport
104104

105+
// Only update i18n files in development setups
106+
config.updateI18nFiles = (env === Environment.development)
107+
105108
// merge legacy values
106109
let keys = Object.keys(config)
107110
const uppercase = /[A-Z]/

0 commit comments

Comments
 (0)