mirror of
https://github.com/discourse/discourse.git
synced 2025-01-19 02:12:46 +08:00
FIX: overriding _MF translations worked only for English
This commit is contained in:
parent
dab0ec1d66
commit
890ffb1eb5
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user