i18n export
doesn't export scopes from js files?
#699
-
I defined a translation scope in a stimulus controller, which is not defined in any erb files, only in the stimulus controller. When I run - app/javascript/controllers/home_controller.js:12:21: en.pages.home.helloWorldFrom
- app/javascript/controllers/home_controller.js:12:21: es.pages.home.helloWorldFrom
- app/javascript/controllers/home_controller.js:12:21: it.pages.home.helloWorldFrom However, when I run With the previous version 3 of i18n-js, I would run
I have a very basic translations:
- file: "app/javascript/src/translations.json"
patterns:
- "*" So I don't believe anything there is preventing the export. Should we still be using a middleware with i18n-js v4? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Actually I found the fix. Simply import { i18n } from "../config/i18n"
const I18n = i18n; Then I use Another way to possibly fix this would be to patch the I also issued a PR on the i18n-js-examples repo to help clear this up: fnando/i18n-js-examples#1 |
Beta Was this translation helpful? Give feedback.
Actually I found the fix. Simply
i18n-tasks missing
oradd-missing
wasn't picking up on the translation strings because now we have lowercasei18n
instead ofI18n
. The only way I could get it to work was to copyi18n
toI18n
:Then I use
I18n.t('scope.string')
instead ofi18n.t('scope.string')
. And nowi18n-tasks missing
is picking up the missing strings in the js files.Another way to possibly fix this would be to patch the
i18n-tasks
gem to accept a lowercasei18n
when scanning, see the related discussion here: glebm/i18n-tasks#453I also issued a PR on the i18n-js-examples repo to help clear this up: fnando/i18n-js-examples#1