Class: Pixab::LocalizationAndroid
Constant Summary
collapse
- File_name =
"strings_ph.xml"
- Exclude_locales =
['zh-Hant']
Instance Method Summary
collapse
#file_mode, #resolve_commands
Instance Method Details
#dir_name(locale) ⇒ Object
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
# File 'lib/LocalizationPlatform.rb', line 176
def dir_name(locale)
suffix = ''
case locale
when 'en'
suffix = ''
when 'fr'
suffix = '-fr-rFR'
when 'ru'
suffix = '-ru-rRU'
when 'zh-Hans'
suffix = '-zh-rCN'
when 'tr'
suffix = '-tr-rTR'
else
suffix = "-#{locale}"
end
return "values#{suffix}"
end
|
#run(localized_info_category, commands) ⇒ Object
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
# File 'lib/LocalizationPlatform.rb', line 152
def run(localized_info_category, commands)
localized_info_category.each do |locale, localized_infos|
if Exclude_locales.include?(locale)
next
end
content_dir_path = dir_name(locale)
if !Utilities.dir_exist(content_dir_path)
FileUtils.mkdir_p content_dir_path
end
content_file_path = "#{content_dir_path}/#{File_name}"
File.open(content_file_path, file_mode) do |file|
file.syswrite("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
file.syswrite("<resources>\n")
localized_infos.each do |localized_info|
value = localized_info['value'].gsub(/['"]/, '\\\\\0')
file.syswrite(" <string name=\"#{localized_info['key']}\">#{value}</string>\n")
end
file.syswrite("</resources>\n")
end
end
end
|