jeresig / i18n-node-2

Lightweight simple translation module for node.js / express.js with dynamic json storage. Uses common __('...') syntax in app and templates.
MIT License
507 stars 79 forks source link

fallback to default locale #42

Closed torvalde closed 9 years ago

torvalde commented 9 years ago

When in production mode and a key does not exist in the current language, the key is displayed. We have some keys that are generated so we want to avoid showing them to the customer even if a translation in the current language is not available, instead we would like to show the translation in the default language.

Would it be ok to first check the translation in the default locale before returning the key?

Something like:

    if (!this.locales[locale][singular]) {
        if (this.devMode) {
            this.locales[locale][singular] = plural ? { one: singular, other: plural } : singular;
            this.writeFile(locale);
        } else {
            locale = this.defaultLocale;
        }
    }
gjuchault commented 9 years ago

Duplicate of https://github.com/jeresig/i18n-node-2/pull/29