문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top