Skip to content

Commit

Permalink
Add the ability to write UTF-16 files.
Browse files Browse the repository at this point in the history
Issue scelis#2
  • Loading branch information
scelis committed Feb 27, 2012
1 parent 1840f1f commit c9f8f1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/twine/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def parse_args
opts.on('-a', '--all', 'Normally, when consuming a string file, Twine will ignore any string keys that do not exist in your master file. This flag will also cause any Android string files that are generated to include strings that have not yet been translated for the current language.') do |a|
@options[:consume_generate_all] = true
end
opts.on('-e', '--encoding ENCODING', 'Twine defaults to encoding all output files in UTF-8. This flag will tell Twine to use an alternate encoding for these files. For example, you could use this to write Apple .strings files in UTF-16. This flag currently only works with Apple .strings files and is currently only supported in Ruby 1.9.3 or greater.') do |e|
@options[:output_encoding] = e
end
opts.on('-o', '--output-file OUTPUT_FILE', 'Write the new strings database to this file instead of replacing the original file. This flag is only useful when running the consume-string-file or consume-loc-drop commands.') do |o|
@options[:output_path] = o
end
Expand Down
3 changes: 2 additions & 1 deletion lib/twine/formatters/apple.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def read_file(path, lang)

def write_file(path, lang)
default_lang = @strings.language_codes[0]
File.open(path, 'w:UTF-8') do |f|
encoding = @options[:output_encoding] || 'UTF-8'
File.open(path, "w:#{encoding}") do |f|
f.puts "/**\n * iOS Strings File\n * Generated by Twine\n * Language: #{lang}\n */"
@strings.sections.each do |section|
printed_section = false
Expand Down

0 comments on commit c9f8f1c

Please sign in to comment.