mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 03:33:39 +08:00
Support for finding new locales in plugins
This commit is contained in:
parent
44081bdf73
commit
fc73de9578
|
@ -25,7 +25,17 @@ class LocaleSiteSetting < EnumSiteSetting
|
||||||
|
|
||||||
def self.supported_locales
|
def self.supported_locales
|
||||||
@lock.synchronize do
|
@lock.synchronize do
|
||||||
@supported_locales ||= Dir.glob(File.join(Rails.root, 'config', 'locales', 'client.*.yml')).map { |x| x.split('.')[-2] }.sort
|
@supported_locales ||= begin
|
||||||
|
app_client_files = Dir.glob(
|
||||||
|
File.join(Rails.root, 'config', 'locales', 'client.*.yml')
|
||||||
|
)
|
||||||
|
|
||||||
|
plugin_client_files = Dir.glob(
|
||||||
|
File.join(Rails.root, 'plugins', '*', 'config', 'locales', 'client.*.yml')
|
||||||
|
)
|
||||||
|
|
||||||
|
(app_client_files + plugin_client_files).map { |x| x.split('.')[-2] }.uniq.sort
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,9 @@ eo:
|
||||||
es:
|
es:
|
||||||
name: Spanish
|
name: Spanish
|
||||||
nativeName: Español
|
nativeName: Español
|
||||||
|
es_MX:
|
||||||
|
name: Spanish
|
||||||
|
nativeName: Español (MX)
|
||||||
et:
|
et:
|
||||||
name: Estonian
|
name: Estonian
|
||||||
nativeName: eesti
|
nativeName: eesti
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe LocaleSiteSetting do
|
||||||
|
|
||||||
describe 'values' do
|
describe 'values' do
|
||||||
it 'returns all the locales that we have translations for' do
|
it 'returns all the locales that we have translations for' do
|
||||||
expect(LocaleSiteSetting.values.map { |x| x[:value] }.sort).to eq(Dir.glob(File.join(Rails.root, 'config', 'locales', 'client.*.yml')).map { |x| x.split('.')[-2] }.sort)
|
expect(LocaleSiteSetting.values.map { |x| x[:value] }).to include(*Dir.glob(File.join(Rails.root, 'config', 'locales', 'client.*.yml')).map { |x| x.split('.')[-2] })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user