From bdeae17d328778e5677dcd8df92003c61db5aa17 Mon Sep 17 00:00:00 2001 From: Gerhard Schlager Date: Mon, 28 May 2018 18:51:19 +0200 Subject: [PATCH] Automatically create locale.js.erb file when adding new locale --- script/pull_translations.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/script/pull_translations.rb b/script/pull_translations.rb index c3bab58ad3..21e4dc31c6 100755 --- a/script/pull_translations.rb +++ b/script/pull_translations.rb @@ -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