FIX: overriding _MF translations worked only for English

This commit is contained in:
Gerhard Schlager 2018-02-07 12:47:01 +01:00
parent dab0ec1d66
commit 890ffb1eb5
2 changed files with 5 additions and 4 deletions

View File

@ -21,7 +21,7 @@ class TranslationOverride < ActiveRecord::Base
data = { value: value }
if key.end_with?('_MF')
_, filename = JsLocaleHelper.find_message_format_locale(['en'], false)
_, filename = JsLocaleHelper.find_message_format_locale([locale], false)
data[:compiled_js] = JsLocaleHelper.compile_message_format(filename, locale, value)
end

View File

@ -46,11 +46,12 @@ describe TranslationOverride do
end
it "stores js for a message format key" do
TranslationOverride.upsert!('en', 'some.key_MF', '{NUM_RESULTS, plural, one {1 result} other {many} }')
TranslationOverride.upsert!('ru', 'some.key_MF', '{NUM_RESULTS, plural, one {1 result} other {many} }')
ovr = TranslationOverride.where(locale: 'en', translation_key: 'some.key_MF').first
ovr = TranslationOverride.where(locale: 'ru', translation_key: 'some.key_MF').first
expect(ovr).to be_present
expect(ovr.compiled_js).to match(/function/)
expect(ovr.compiled_js).to start_with('function')
expect(ovr.compiled_js).to_not match(/Invalid Format/i)
end
end