2018-04-27 12:01:34 -05:00
|
|
|
#!/usr/bin/env ruby
|
2014-04-14 10:41:36 -05:00
|
|
|
|
2018-04-27 12:01:34 -05:00
|
|
|
require 'bundler/inline'
|
2014-04-14 10:41:36 -05:00
|
|
|
|
2018-04-27 12:01:34 -05:00
|
|
|
gemfile(true) do
|
|
|
|
gem 'translations-manager', git: 'https://github.com/discourse/translations-manager.git'
|
2014-04-14 10:41:36 -05:00
|
|
|
end
|
2017-12-06 10:04:51 -06:00
|
|
|
|
2018-04-27 12:01:34 -05:00
|
|
|
require 'translations_manager'
|
2014-04-14 10:41:36 -05:00
|
|
|
|
2018-04-27 12:01:34 -05:00
|
|
|
def expand_path(path)
|
|
|
|
File.expand_path("../../#{path}", __FILE__)
|
2014-04-14 10:41:36 -05:00
|
|
|
end
|
|
|
|
|
2018-04-27 12:01:34 -05: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 15:30:28 -05:00
|
|
|
end
|
|
|
|
|
2018-04-27 12:01:34 -05:00
|
|
|
YML_DIRS = ['config/locales',
|
|
|
|
'plugins/poll/config/locales',
|
|
|
|
'plugins/discourse-details/config/locales',
|
2018-05-04 03:13:15 -05:00
|
|
|
'plugins/discourse-local-dates/config/locales',
|
2018-04-27 12:01:34 -05:00
|
|
|
'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 17:15:44 -05:00
|
|
|
|
2018-04-27 12:01:34 -05:00
|
|
|
if TranslationsManager::SUPPORTED_LOCALES != supported_locales
|
|
|
|
STDERR.puts <<~MESSAGE
|
2016-07-26 17:15:44 -05:00
|
|
|
|
2018-04-27 12:01:34 -05: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 17:15:44 -05:00
|
|
|
|
2018-04-27 12:01:34 -05:00
|
|
|
The following locales are currently supported by Discourse:
|
2016-07-26 17:15:44 -05:00
|
|
|
|
2018-04-27 12:01:34 -05:00
|
|
|
MESSAGE
|
2016-07-26 17:15:44 -05:00
|
|
|
|
2018-04-27 12:01:34 -05:00
|
|
|
STDERR.puts locales.map { |l| "'#{l}'" }.join(",\n")
|
|
|
|
exit 1
|
2016-07-26 17:15:44 -05:00
|
|
|
end
|
|
|
|
|
2018-04-27 12:01:34 -05:00
|
|
|
TranslationsManager::TransifexUpdater.new(YML_DIRS, YML_FILE_PREFIXES, *ARGV).perform(tx_config_filename: TX_CONFIG)
|