According to the migration guide, export_i18n_js has been removed without an equivalent.
I tried fetching the generated JSON files via fetch but the problem is that since that is non blocking, other scripts which rely on the global I18n error out.
This is how things work right now
In my haml file, I do
:javascript
locale = "#{I18n.locale.to_s}"
And then I access this global from my main script to fetch the json files.
I'm not sure if this has any performances penalties but it does look kind of ugly. Is there a better way to do this? Having the ability to export JS files would solve this issue but I assume there's a good way to do it without it.
According to the migration guide,
export_i18n_js
has been removed without an equivalent.I tried fetching the generated JSON files via
fetch
but the problem is that since that is non blocking, other scripts which rely on the globalI18n
error out.This is how things work right now
In my haml file, I do
And then I access this global from my main script to fetch the json files.
But while this waits on the main script, it sends control to other scripts, which rely on
I18n
.My workaround for this right now is reading the file via Ruby and injecting it in the javascript. Something like this.
I'm not sure if this has any performances penalties but it does look kind of ugly. Is there a better way to do this? Having the ability to export JS files would solve this issue but I assume there's a good way to do it without it.