Skip to content

A platform for community discussion. Free, open, simple.

FIX: overriding _MF translations worked only for English

Gerhard Schlager890ffb1eb56c
diff --git a/app/models/translation_override.rb b/app/models/translation_override.rb
index ea3859930c5..f60b19545c5 100644
--- a/app/models/translation_override.rb
+++ b/app/models/translation_override.rb
@@ -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
diff --git a/spec/models/translation_override_spec.rb b/spec/models/translation_override_spec.rb
index 9929d325f66..7f31c015a61 100644
--- a/spec/models/translation_override_spec.rb
+++ b/spec/models/translation_override_spec.rb
@@ -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