discourse/app/assets/javascripts/locales
Godfrey Chan 2e00482ac4
DEV: convert I18n pseudo package into real package (discourse-i18n) (#23867)
Currently, `window.I18n` is defined in an old school hand written
script, inlined into locale/*.js by the Rails asset pipeline, and
then the global variable is shimmed into a pseudo AMD module later
in `module-shims.js`.

This approach has some problems – for one thing, when we add a new
V2 addon (e.g. in #23859), Embroider/Webpack is stricter about its
dependencies and won't let you `import from "I18n";` when `"I18n"`
isn't listed as one of its `dependencies` or `peerDependencies`.

This moves `I18n` into a real package – `discourse-i18n`. (I was
originally planning to keep the `I18n` name since it's a private
package anyway, but NPM packages are supposed to have lower case
names and that may cause problems with other tools.)

This package defines and exports a regular class, but also defines
the default global instance for backwards compatibility. We should
use the exported class in tests to make one-off instances without
mutating the global instance and having to clean it up after the
test run. However, I did not attempt that refactor in this PR.

Since `discourse-i18n` is now included by the app, the locale
scripts needs to be loaded after the app chunks. Since no "real"
work happens until later on when we kick things off in the boot
script, the order in which the script tags appear shouldn't be a
problem. Alternatively, we can rework the locale bundles to be more
lazy like everything else, and require/import them into the app.

I avoided renaming the imports in this commit since that would be
quite noisy and drowns out the actual changes here. Instead, I used
a Webpack alias to redirect the current `"I18n"` import to the new
package for the time being. In a separate commit later on, I'll
rename all the imports in oneshot and remove the alias. As always,
plugins and the legacy bundles (admin/wizard) still relies on the
runtime AMD shims regardless.

For the most part, I avoided refactoring the actual I18n code too
much other than making it a class, and some light stuff like `var`
into `let`.

However, now that it is in a reasonable format to work with (no
longer inside the global script context!) it may also be a good
opportunity to refactor and make clear what is intended to be
public API vs internal implementation details.

Speaking of, I took the librety to make `PLACEHOLDER`, `SEPARATOR`
and `I18nMissingInterpolationArgument` actual constants since it
seemed pretty clear to me those were just previously stashed on to
the `I18n` global to avoid polluting the global namespace, rather
than something we expect the consumers to set/replace.
2023-10-12 14:44:01 +01:00
..
ar.js.erb UX: Make moment.js produce Arabic numerals instead of Hindi numerals in the Arabic locale (#11788) 2021-01-21 22:11:51 +03:00
be.js.erb FEATURE: Add Belarusian language 2019-07-04 11:37:37 +02:00
bg.js.erb FEATURE: Add Bulgarian language 2018-05-29 21:07:17 +02:00
bs_BA.js.erb Create bs_BA.js.erb 2015-05-12 16:16:10 +04:30
ca.js.erb FEATURE: Catalan Translations (#5404) 2017-12-07 10:36:25 +01:00
cs.js.erb FIX: eradicate I18n fallback issues 💣 2017-02-24 11:31:21 +01:00
da.js.erb
de.js.erb
el.js.erb FEATURE: Greek language support, thanks to Vasilis Vlachokyriakos 2017-03-01 15:52:55 -05:00
en_GB.js.erb FEATURE: Add English (UK) as locale (#11768) 2021-01-20 21:32:22 +01:00
en.js.erb Allow reloading of translation keys for plugins in development mode 2017-08-09 13:58:20 -04:00
es.js.erb
et.js.erb add Estonian language files 2016-06-01 15:25:21 +05:30
fa_IR.js.erb FIX: eradicate I18n fallback issues 💣 2017-02-24 11:31:21 +01:00
fi.js.erb
fr.js.erb
gl.js.erb Support for Galician language js bundle added 2016-03-22 16:48:00 +01:00
he.js.erb
hr.js.erb FEATURE: Add Croatian language (#17130) 2022-06-18 00:18:22 +02:00
hu.js.erb Add Hungarian locale (#6260) 2018-08-13 01:02:35 +02:00
hy.js.erb FEATURE: Add Armenian language 2019-03-28 14:24:14 +01:00
i18n.js DEV: convert I18n pseudo package into real package (discourse-i18n) (#23867) 2023-10-12 14:44:01 +01:00
id.js.erb
it.js.erb
ja.js.erb FIX: eradicate I18n fallback issues 💣 2017-02-24 11:31:21 +01:00
ko.js.erb
lt.js.erb FEATURE: Add Lithuanian locale 2018-09-27 05:26:38 +02:00
lv.js.erb FEATURE: add Latvian language 2017-08-15 11:40:00 -04:00
nb_NO.js.erb
nl.js.erb
pl_PL.js.erb
pt_BR.js.erb
pt.js.erb
ro.js.erb FIX: eradicate I18n fallback issues 💣 2017-02-24 11:31:21 +01:00
ru.js.erb FIX: eradicate I18n fallback issues 💣 2017-02-24 11:31:21 +01:00
sk.js.erb FIX: eradicate I18n fallback issues 💣 2017-02-24 11:31:21 +01:00
sl.js.erb Add Slovenian translations 2018-03-06 20:51:41 +01:00
sq.js.erb
sr.js.erb CRLF caused problems with launch script 2017-12-19 13:55:17 +01:00
sv.js.erb
sw.js.erb Add Swahili language 2018-07-16 18:11:38 +02:00
te.js.erb Add Telugu translation files 2015-02-09 20:46:31 +05:30
th.js.erb FEATURE: add Thai language 2017-08-25 12:33:09 -04:00
tr_TR.js.erb FIX: eradicate I18n fallback issues 💣 2017-02-24 11:31:21 +01:00
uk.js.erb FIX: eradicate I18n fallback issues 💣 2017-02-24 11:31:21 +01:00
ur.js.erb Add initial Urdu support with RTL direction 2016-12-03 23:17:51 -05:00
vi.js.erb add Vietnamese locale js file 2016-03-01 10:49:50 +05:30
zh_CN.js.erb
zh_TW.js.erb