Closed chinhnguyen93 closed 1 year ago
I face two issues when use this gem in Rails app (Rails 5.0, ruby 2.7.6) as below: I18n.t is not a function in coffee script file I18n is not defined in html slim file
I18n.t is not a function
I18n is not defined
Gemfile: gem 'i18n-js' Gemfile.lock i18n-js (4.0.1) config/i18n.yml
gem 'i18n-js'
i18n-js (4.0.1)
translations: - file: "app/assets/javascripts/i18n/%{locale}.js" patterns: - "*" - "!*.activerecord" - "!*.errors" - "!*.number.nth"
coffee script: I18n.t("javascripts.instance.xxx") -> this raise error: I18n.t is not a function
I18n.t("javascripts.instance.xxx")
HTML:
javascript: I18n.defaultLocale = "#{I18n.default_locale}"; I18n.locale = "#{I18n.locale}";
this raise error: I18n is not defined
Please follow the migration guide from v3 to v4. https://github.com/fnando/i18n-js/blob/main/MIGRATING_FROM_V3_TO_V4.md
Description
I face two issues when use this gem in Rails app (Rails 5.0, ruby 2.7.6) as below:
I18n.t is not a function
in coffee script fileI18n is not defined
in html slim fileGemfile:
gem 'i18n-js'
Gemfile.locki18n-js (4.0.1)
config/i18n.ymlcoffee script:
I18n.t("javascripts.instance.xxx")
-> this raise error:I18n.t is not a function
HTML:
this raise error:
I18n is not defined