Question

I am trying to store a default translation if a translation is missing in Rails.
After much struggle I came up with this:

backend = I18n.backend
if not backend.exists?(locale, key)
  backend.store_translations(locale, {key => locale.to_s + "-" + key.to_s})
end

The problem is, it stores the default values but it does not find them. Any idea what is wrong here?

Was it helpful?

Solution

After so much headache, I found the problem:

It is because the dots in my keys are converted to their unicode character when stored, so, they are not found. For example actions.save is converted to actions\u0001save.

I don't know why this happens.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top