Upgrade i18n-js to v4
andyduong1920 opened this issue · comments
Andy Duong commented
Why
-
We are using both i18n-js Ruby and i18n-js Node package v3
-
To upgrade from v3 to v4, it requires lot of changes, I tried it but failed in some step, some task I remember was
- Update the
app/javascript/global.js
following the guide on https://www.npmjs.com/package/i18n-js?activeTab=readme
import { I18n } from "i18n-js"; import translations from "./translations.json"; const i18n = new I18n(translations);
- Update the
- Remove the
config.middleware.use I18n::JS::Middleware
as v4 doesn't have it - Rename the
config/i18n-js.yml
toconfig/i18n.yml
and update the content
translations:
- file: 'app/javascript/translations/translations.js'
pattern:
- '*'
- Replace the task
i18n:js:export
toi18n export
- Update the relative JS files like
app/javascript/initializers/i18n.js
I tried all of them, but having 1 last issue on JS is the I18n module is not define
not sure about that, I create this dedicate ticket for this upgrading, happy coding 🍺
Who Benefits?
Developers