This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.
Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
When a plugin registers a language and sets fallbackLocale="en", fallback strings were missing. This commit strips any duplicate ":en" symbols when loading merged translations.
Uses github.com/discourse/moment-timezone-names-translations to translate timezone names.
Plugins can also provide their own timezone name translations.
FIX: client's translation overrides were not working when the current locale was missing a key
FIX: ExtraLocalesController.show was not properly handling multiple translations
FIX: JsLocaleHelper#output_locale was not properly handling multiple translations
FIX: ExtraLocalesController.show's spec which was randomly failing
FIX: JsLocaleHelper#output_locale was muting cached translations hashes
REFACTOR: move 'enableVerboseLocalization' to the 'localization' initializer
REFACTOR: remove unused I18n.js methods (getFallbacks, localize, parseDate, toTime, strftime, toCurrency, toPercentage)
REFACTOR: remove all I18n.pluralizationRules and instead use MessageFormat's pluralization rules
TEST: add tests for localization initializer
TEST: add tests for I18n.js
moment.js uses a different naming conventions for locale files.
E.g. "zh-zn" instead of "zh_ZN" and "nb" instead of "nb_NO"
This change allows us to use the locale files without renaming which
makes future upgrades of moment.js a lot easier.
This patch sets I18n.defaultLocale in the Discourse.start() script block (it
was formerly always 'en') to SiteSetting.default_locale, and patches
translate() to perform fallback to defaultLocale followed by english.
Additionally, when enable_verbose_localization() is called, no fallbacks will
be performed.
It also memoizes the file loading operations in JsLocaleHelper and strips out
translations from the fallbacks that are also present in a prefered language,
to minimize file size.