It's a small library to provide the I18n translations on the Javascript. It comes with Rails support.
i18n.translations
object is global - one for the entire app. Is there some built-in way of keeping the translations local to each i18n object that I import in my compoents?
Hi!
I'm using the i18n-js with multitenancy and at my rails application the translation file is defined by tenant name, so we have 4 different files, 1 is the en.yml default and the others is the tenant_name.yml. At the ApplicationController.rb, the file is selected by the Tenant, and used by the default translation en
.
Here is the code
def set_tenant_translation
translation_path = 'config/locales/' \
"#{Tenant.current.prefix}/#{locale}.yml"
if File.exist?(translation_path)
i18n = YAML.load(File.read(translation_path))
I18n.backend.store_translations :en, i18n.fetch(locale.to_s)
end
yield
end
On my local environment works perfectly, but on staging and production dont. Does anybody know why?
Hi All,
Is there a way to create a "scoped" I18n object with just the translations that I give it? I'm thinking something like new I18n({ header: 'Test', section: { header: 'Section' } }).t('section.header')
For context, I have a situation where I'm passing a t
function as a property all the way down my react tree, and at the top-level I am using https://github.com/reactjs/react-rails to inject my translations as a property into the top-level React component. This lets me inject just the translations I need for this particular tree, instead of writing my entire translation file.
strftime
. Would love some feedback! fnando/i18n-js#537
No such file or directory @ rb_sysopen - /rails-root/tmp/cache/i18n-js.yml
I see the tmp/cache/i18n-js.yml file gets updated if
#
https://github.com/fnando/i18n-js/blob/main/lib/i18n/js/middleware.rb
Is it possible to disable this?