mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
FIX: "Customize Text" showed compiled MessageFormat string for overridden _MF
translations
This commit is contained in:

committed by
Gerhard Schlager

parent
e19a7a7c8d
commit
4cd5158974
@ -138,6 +138,21 @@ RSpec.describe Admin::SiteTextsController do
|
||||
expect(response.parsed_body['site_texts']).to be_empty
|
||||
end
|
||||
|
||||
it "returns site text from fallback locale if current locale doesn't have a translation" do
|
||||
TranslationOverride.upsert!(:en, 'js.summary.description_time_MF', 'description_time_MF override')
|
||||
TranslationOverride.upsert!(:en, 'education.new-topic', 'education.new-topic override')
|
||||
|
||||
get "/admin/customize/site_texts.json", params: { q: 'js.summary.description_time_MF', locale: 'en_GB' }
|
||||
expect(response.status).to eq(200)
|
||||
value = response.parsed_body['site_texts'].find { |text| text['id'] == 'js.summary.description_time_MF' }['value']
|
||||
expect(value).to eq('description_time_MF override')
|
||||
|
||||
get "/admin/customize/site_texts.json", params: { q: 'education.new-topic', locale: 'en_GB' }
|
||||
expect(response.status).to eq(200)
|
||||
value = response.parsed_body['site_texts'].find { |text| text['id'] == 'education.new-topic' }['value']
|
||||
expect(value).to eq('education.new-topic override')
|
||||
end
|
||||
|
||||
context 'plural keys' do
|
||||
before do
|
||||
I18n.backend.store_translations(:en, colour: { one: '%{count} colour', other: '%{count} colours' })
|
||||
@ -272,6 +287,29 @@ RSpec.describe Admin::SiteTextsController do
|
||||
expect(response.status).to eq(400)
|
||||
end
|
||||
|
||||
it "returns site text from fallback locale if current locale doesn't have a translation" do
|
||||
TranslationOverride.upsert!(:en, 'js.summary.description_time_MF', 'description_time_MF override')
|
||||
TranslationOverride.upsert!(:en, 'education.new-topic', 'education.new-topic override')
|
||||
|
||||
get "/admin/customize/site_texts/js.summary.description_time_MF.json", params: { locale: 'en_GB' }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = response.parsed_body
|
||||
site_text = json['site_text']
|
||||
|
||||
expect(site_text['id']).to eq('js.summary.description_time_MF')
|
||||
expect(site_text['value']).to eq('description_time_MF override')
|
||||
|
||||
get "/admin/customize/site_texts/education.new-topic.json", params: { locale: 'en_GB' }
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
json = response.parsed_body
|
||||
site_text = json['site_text']
|
||||
|
||||
expect(site_text['id']).to eq('education.new-topic')
|
||||
expect(site_text['value']).to eq('education.new-topic override')
|
||||
end
|
||||
|
||||
context 'plural keys' do
|
||||
before do
|
||||
I18n.backend.store_translations(:en, colour: { one: '%{count} colour', other: '%{count} colours' })
|
||||
|
Reference in New Issue
Block a user