mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-02 12:10:33 +08:00
Previously, locale bundles were using `require()` directly, and were very sensitive to load order. This made it very hard to refactor things, especially for our upcoming move to Vite. This commit updates the four types of locale bundle to contain only very simple JS code, with no dependencies at the top level. They simply add POJO and functions to the `window._discourse_locale_data` global. When `discourse-i18n` is loaded, it checks that global, loads up the data, and executes the functions (passing in any dependencies like messageformat/runtime where required). Changes in the HTML files are to bring the locale bundles up to the first position, since they no longer have any dependencies, and we need to be 100% sure they're loaded before discourse-i18n. Tests are updated for the new bundle format, and the most complex ones have been converted to system specs, so that we no longer need to create a mock environment for executing messageformat/discourse-i18n/etc. `lib/deprecated` changes (and associated pretty-text changes) are to make the dependencies more formalized, because `require()` is subject to race conditions, which started being hit following the locale refactor. --------- Co-authored-by: Jarek Radosz <jradosz@gmail.com> |
||
|---|---|---|
| .. | ||
| helpers.rb | ||
| shims.js | ||
| vendor-shims.js | ||