Closed sonureddoorz closed 4 years ago
How/where do you call I18n.t
?
Maybe try adding window.I18n = I18n
to see if it's context related issue
Sorry not working for me. :( I have also followed this link but not succeeded. Still not working any functions of I18n-js. https://github.com/fnando/i18n-js/issues/514
From what I see your home.js
createDataTable
is trying to call I18n.t("something")
So I think I18n
import should be present in that file
If not, it's relying on the global I18n
(which is why I suggesting adding window.I18n = I18n
)
Did you try to run I18n.t("something")
on console manually after adding window.I18n = I18n
?
At least you can find out of the import is not working or the import is not placed in the right place
When I added below code in home.js, error is removed on page reload import I18n from 'i18n-js' window.I18n = I18n But running code on console manually after adding window.I18n = I18n still it is showing the same error. :(
I am not sure how you generates your translations
Here is my example:
app/assets/javascripts/plugins/i18n-js/index.ts.erb
<%# encoding: UTF-8 %>
// Tell webpack to watch these files
// https://github.com/usabilityhub/rails-erb-loader#dependencies
/* rails-erb-loader-dependencies ./../config/locales/ */
import I18n from "i18n-js"
I18n.translations = <%= I18n::JS.filtered_translations.to_json %>;
export default I18n
I think it's because binding in 3.5.1, not sure My app is breaking saying missing translations for 3.5.1, but 3.5.0 everything works fine
Already fixed in my app.
Alright I am closing this coz issue author reported success
@chakrihacker Yours might be another issue Please open an issue with some details like code example so I can try to reproduce your issue Or create a failed test case to prove something is broken
ok @PikachuEXE
Facing lots of issues while integrating i18n-js with webpacker in ruby on rails application:-
Steps which I tried :-
window.jQuery = $; window.$ = $; require("@rails/ujs").start() require("turbolinks").start()
require("@rails/activestorage").start() require("channels") require("jquery") require("jquery-ui") require( 'datatables.net-se' ) import 'select2'; import moment from 'moment' window.moment = moment import I18n from 'i18n-js'