forked from code-dot-org/code-dot-org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-codeorg-out
More file actions
executable file
·66 lines (54 loc) · 2.08 KB
/
Copy pathsync-codeorg-out
File metadata and controls
executable file
·66 lines (54 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env ruby
# Distribute downloaded translations from i18n/locales
# back to blockly-core, apps, pegasus, and dashboard.
require File.expand_path('../../pegasus/src/env', __FILE__)
require 'cdo/languages'
require 'fileutils'
def push_out_translated_files
rename_from_crowdin_name_to_locale
exec "bin/i18n-codeorg/out.sh"
copy_untranslated_apps
cleanup_portuguese_codes
rebuild_blockly_js_files
end
# Files downloaded from Crowdin are organized by language name,
# rename folders to be organized by locale
def rename_from_crowdin_name_to_locale
Languages.get_crowdin_name_and_locale.each do |prop|
if File.directory?("i18n/locales/#{prop[:crowdin_name_s]}/")
FileUtils.cp_r "i18n/locales/#{prop[:crowdin_name_s]}/.", "i18n/locales/#{prop[:locale_s]}"
FileUtils.rm_r "i18n/locales/#{prop[:crowdin_name_s]}"
end
end
end
# For untranslated apps, copy English file for all locales
def copy_untranslated_apps
untranslated_apps = %w(applab calc eval gamelab netsim)
Languages.get_locale.each do |prop|
if prop[:locale_s] != 'en-US'
untranslated_apps.each do |app|
app_locale = prop[:locale_s].gsub('-', '_').downcase!
FileUtils.cp_r "apps/i18n/#{app}/en_us.json", "apps/i18n/#{app}/#{app_locale}.json"
end
end
end
end
def cleanup_portuguese_codes
dashboard_categories = %w(data devise dsls instructions scripts slides unplugged)
# Fix portuguese codes
file = "dashboard/config/locales/pt-BR.yml"
File.write(file, File.read(file).gsub(/"pt-BR":/, '"pt":'))
file = "dashboard/config/locales/pt-PT.yml"
File.write(file, File.read(file).gsub(/"pt":/, '"pt-PT":'))
dashboard_categories.each do |dashboard|
file = "dashboard/config/locales/#{dashboard}.pt-BR.yml"
File.write(file, File.read(file).gsub(/"pt-BR":/, '"pt":'))
file = "dashboard/config/locales/#{dashboard}.pt-PT.yml"
File.write(file, File.read(file).gsub(/"pt":/, '"pt-PT":'))
end
end
def rebuild_blockly_js_files
exec "blockly-core/i18n/codeorg-messages.sh"
FileUtils.cp_r 'blockly-core/msg/js/.', 'apps/lib/blockly/'
end
push_out_translated_files