Automatically create locale.js.erb file when adding new locale

This commit is contained in:
Gerhard Schlager 2018-05-28 18:51:19 +02:00
parent 87edde3113
commit bdeae17d32
1 changed files with 12 additions and 0 deletions

View File

@ -28,6 +28,7 @@ YML_DIRS = ['config/locales',
'plugins/discourse-presence/config/locales'].map { |dir| expand_path(dir) }
YML_FILE_PREFIXES = ['server', 'client']
TX_CONFIG = expand_path('.tx/config')
JS_LOCALE_DIR = expand_path('app/assets/javascripts/locales')
if TranslationsManager::SUPPORTED_LOCALES != supported_locales
STDERR.puts <<~MESSAGE
@ -45,3 +46,14 @@ if TranslationsManager::SUPPORTED_LOCALES != supported_locales
end
TranslationsManager::TransifexUpdater.new(YML_DIRS, YML_FILE_PREFIXES, *ARGV).perform(tx_config_filename: TX_CONFIG)
supported_locales.each do |locale|
filename = File.join(JS_LOCALE_DIR, "#{locale}.js.erb")
next if File.exists?(filename)
File.write(filename, <<~ERB)
//= depend_on 'client.#{locale}.yml'
//= require locales/i18n
<%= JsLocaleHelper.output_locale(:#{locale}) %>
ERB
end