discourse/script/pull_translations.rb
Gerhard Schlager ef80341806 Update pull_translations script to work with latest Transifex changes
* supports resources created with Transifex's YML handler version 3
* uses translations-manager gem
* makes sure that the locales supported by translations-manager are not out of sync
* update the lang_map in tx client config before pulling translations
2018-04-27 19:20:19 +02:00

47 lines
1.4 KiB
Ruby
Executable File

#!/usr/bin/env ruby
require 'bundler/inline'
gemfile(true) do
gem 'translations-manager', git: 'https://github.com/discourse/translations-manager.git'
end
require 'translations_manager'
def expand_path(path)
File.expand_path("../../#{path}", __FILE__)
end
def supported_locales
Dir.glob(expand_path('config/locales/client.*.yml'))
.map { |x| x.split('.')[-2] }
.select { |x| x != 'en' }
.sort
end
YML_DIRS = ['config/locales',
'plugins/poll/config/locales',
'plugins/discourse-details/config/locales',
'plugins/discourse-narrative-bot/config/locales',
'plugins/discourse-nginx-performance-report/config/locales',
'plugins/discourse-presence/config/locales'].map { |dir| expand_path(dir) }
YML_FILE_PREFIXES = ['server', 'client']
TX_CONFIG = expand_path('.tx/config')
if TranslationsManager::SUPPORTED_LOCALES != supported_locales
STDERR.puts <<~MESSAGE
The supported locales are out of sync.
Please update the TranslationsManager::SUPPORTED_LOCALES in translations-manager.
https://github.com/discourse/translations-manager
The following locales are currently supported by Discourse:
MESSAGE
STDERR.puts locales.map { |l| "'#{l}'" }.join(",\n")
exit 1
end
TranslationsManager::TransifexUpdater.new(YML_DIRS, YML_FILE_PREFIXES, *ARGV).perform(tx_config_filename: TX_CONFIG)