2018-04-27 13:01:34 -04:00
|
|
|
#!/usr/bin/env ruby
|
2014-04-14 11:41:36 -04:00
|
|
|
|
2018-04-27 13:01:34 -04:00
|
|
|
require 'bundler/inline'
|
2014-04-14 11:41:36 -04:00
|
|
|
|
2018-04-27 13:01:34 -04:00
|
|
|
gemfile(true) do
|
|
|
|
gem 'translations-manager', git: 'https://github.com/discourse/translations-manager.git'
|
2014-04-14 11:41:36 -04:00
|
|
|
end
|
2017-12-06 11:04:51 -05:00
|
|
|
|
2018-04-27 13:01:34 -04:00
|
|
|
require 'translations_manager'
|
2014-04-14 11:41:36 -04:00
|
|
|
|
2018-04-27 13:01:34 -04:00
|
|
|
def expand_path(path)
|
|
|
|
File.expand_path("../../#{path}", __FILE__)
|
2014-04-14 11:41:36 -04:00
|
|
|
end
|
|
|
|
|
2018-04-27 13:01:34 -04:00
|
|
|
def supported_locales
|
|
|
|
Dir.glob(expand_path('config/locales/client.*.yml'))
|
|
|
|
.map { |x| x.split('.')[-2] }
|
|
|
|
.select { |x| x != 'en' }
|
|
|
|
.sort
|
2015-09-18 16:30:28 -04:00
|
|
|
end
|
|
|
|
|
2018-04-27 13:01:34 -04:00
|
|
|
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')
|
2016-07-26 18:15:44 -04:00
|
|
|
|
2018-04-27 13:01:34 -04:00
|
|
|
if TranslationsManager::SUPPORTED_LOCALES != supported_locales
|
|
|
|
STDERR.puts <<~MESSAGE
|
2016-07-26 18:15:44 -04:00
|
|
|
|
2018-04-27 13:01:34 -04:00
|
|
|
The supported locales are out of sync.
|
|
|
|
Please update the TranslationsManager::SUPPORTED_LOCALES in translations-manager.
|
|
|
|
https://github.com/discourse/translations-manager
|
2016-07-26 18:15:44 -04:00
|
|
|
|
2018-04-27 13:01:34 -04:00
|
|
|
The following locales are currently supported by Discourse:
|
2016-07-26 18:15:44 -04:00
|
|
|
|
2018-04-27 13:01:34 -04:00
|
|
|
MESSAGE
|
2016-07-26 18:15:44 -04:00
|
|
|
|
2018-04-27 13:01:34 -04:00
|
|
|
STDERR.puts locales.map { |l| "'#{l}'" }.join(",\n")
|
|
|
|
exit 1
|
2016-07-26 18:15:44 -04:00
|
|
|
end
|
|
|
|
|
2018-04-27 13:01:34 -04:00
|
|
|
TranslationsManager::TransifexUpdater.new(YML_DIRS, YML_FILE_PREFIXES, *ARGV).perform(tx_config_filename: TX_CONFIG)
|