2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

Add plugins/poll and discourse_imgur translation files to transifex

This commit is contained in:
Neil Lalonde 2014-04-24 10:11:23 -04:00
parent c52ee665b4
commit 69dee799e9
12 changed files with 83 additions and 37 deletions

View file

@ -21,6 +21,36 @@ trans.ko_KR = config/locales/server.ko.yml
trans.pt_PT = config/locales/server.pt.yml
type = YML
[discourse-org.pollclientenyml]
file_filter = plugins/poll/config/locales/client.<lang>.yml
source_file = plugins/poll/config/locales/client.en.yml
source_lang = en
trans.es_ES = plugins/poll/config/locales/client.es.yml
trans.fr_FR = plugins/poll/config/locales/client.fr.yml
#trans.ko_KR = plugins/poll/config/locales/client.ko.yml
#trans.pt_PT = plugins/poll/config/locales/client.pt.yml
type = YML
[discourse-org.pollserverenyml]
file_filter = plugins/poll/config/locales/server.<lang>.yml
source_file = plugins/poll/config/locales/server.en.yml
source_lang = en
trans.es_ES = plugins/poll/config/locales/server.es.yml
trans.fr_FR = plugins/poll/config/locales/server.fr.yml
#trans.ko_KR = plugins/poll/config/locales/server.ko.yml
#trans.pt_PT = plugins/poll/config/locales/server.pt.yml
type = YML
[discourse-org.imgurserverenyml]
file_filter = vendor/gems/discourse_imgur/lib/discourse_imgur/locale/server.<lang>.yml
source_file = vendor/gems/discourse_imgur/lib/discourse_imgur/locale/server.en.yml
source_lang = en
trans.es_ES = vendor/gems/discourse_imgur/lib/discourse_imgur/locale/server.es.yml
trans.fr_FR = vendor/gems/discourse_imgur/lib/discourse_imgur/locale/server.fr.yml
#trans.ko_KR = vendor/gems/discourse_imgur/lib/discourse_imgur/locale/server.ko.yml
trans.pt_PT = vendor/gems/discourse_imgur/lib/discourse_imgur/locale/server.pt.yml
type = YML
[discourse-org.403html]
file_filter = public/403.<lang>.html
source_file = public/403.html

View file

@ -33,7 +33,7 @@ unless $?.success?
exit $?.exitstatus
end
yml_file_comments = <<END
YML_FILE_COMMENTS = <<END
# encoding: utf-8
#
# Never edit this file. It will be overwritten when translations are pulled from Transifex.
@ -42,12 +42,24 @@ yml_file_comments = <<END
# https://www.transifex.com/projects/p/discourse-pt-br/
END
ALL_LOCALES = Dir.glob( File.expand_path("../../config/locales/client.*.yml", __FILE__) ).map {|x| x.split('.')[-2]}.sort
LOCALE_MAPPINGS = [['fr', 'fr_FR'],
['es', 'es_ES'],
['pt', 'pt_PT'],
['ko', 'ko_KR']]
YML_DIRS = ['config/locales',
'plugins/poll/config/locales',
'vendor/gems/discourse_imgur/lib/discourse_imgur/locale']
# Change root element in yml files for some languages because Transifex uses a different
# locale code.
[['fr', 'fr_FR'], ['es', 'es_ES'], ['pt', 'pt_PT'], ['ko', 'ko_KR']].each do |ours, theirs|
LOCALE_MAPPINGS.each do |ours, theirs|
['client', 'server'].each do |base|
YML_DIRS.each do |dir|
contents = []
file_name = File.expand_path("../../config/locales/#{base}.#{ours}.yml", __FILE__)
file_name = File.expand_path("../../#{dir}/#{base}.#{ours}.yml", __FILE__)
found = false
next unless File.exists?(file_name)
File.open(file_name, 'r') do |file|
@ -62,20 +74,24 @@ END
end
File.open(file_name, 'w+') do |f|
f.puts(yml_file_comments, '') unless contents[0][0] == '#'
f.puts(YML_FILE_COMMENTS, '') unless contents[0][0] == '#'
f.puts contents
end
end
end
end
(Dir.glob( File.expand_path("../../config/locales/client.*.yml", __FILE__) ).map {|x| x.split('.')[-2]}.sort - ['fr', 'es', 'pt', 'ko']).each do |locale|
# Add comments to the top of files
(ALL_LOCALES - LOCALE_MAPPINGS.map(&:first)).each do |locale|
['client', 'server'].each do |base|
file_name = File.expand_path("../../config/locales/#{base}.#{locale}.yml", __FILE__)
YML_DIRS.each do |dir|
file_name = File.expand_path("../../#{dir}/#{base}.#{locale}.yml", __FILE__)
next unless File.exists?(file_name)
contents = File.readlines(file_name)
File.open(file_name, 'w+') do |f|
f.puts(yml_file_comments, '') unless contents[0][0] == '#'
f.puts(YML_FILE_COMMENTS, '') unless contents[0][0] == '#'
f.puts contents
end
end
end
end