From d0eec7d4e8b09b6ef3abbfcabbfa01a59acfaf2e Mon Sep 17 00:00:00 2001 From: Filippo Del Frari Date: Thu, 7 Nov 2019 17:23:17 +0100 Subject: [PATCH 1/2] Added csv2android region management --- lib/babelish/csv2android.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/babelish/csv2android.rb b/lib/babelish/csv2android.rb index 76f2239..5d13f08 100644 --- a/lib/babelish/csv2android.rb +++ b/lib/babelish/csv2android.rb @@ -13,7 +13,8 @@ def language_filepaths(language) require 'pathname' output_name = "strings.xml" output_name = "#{@output_basename}.xml" unless @output_basename.empty? - filepath = Pathname.new(@file_path) + "values-#{language.code}" + output_name + region = language.region.to_s.empty? ? "" : "-r#{language.region}" + filepath = Pathname.new(@file_path) + "values-#{language.code}#{region}" + output_name return filepath ? [filepath] : [] end From 860677e3ae7fed7872f7be13a01b8812d55c4fc3 Mon Sep 17 00:00:00 2001 From: Filippo Del Frari Date: Thu, 7 Nov 2019 17:35:20 +0100 Subject: [PATCH 2/2] Added test for csv2android with region --- .../babelish/commands/test_command_csv2android.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/babelish/commands/test_command_csv2android.rb b/test/babelish/commands/test_command_csv2android.rb index 9bd1744..f76108c 100644 --- a/test/babelish/commands/test_command_csv2android.rb +++ b/test/babelish/commands/test_command_csv2android.rb @@ -16,6 +16,21 @@ def test_csv2android_with_multiple_2_languages system("rm -rf ./values-fr/") end + def test_csv2android_with_multiple_2_languages_with_region + options = { + :filename => "test/data/test_data_multiple_langs.csv", + :langs => {"English" => "en-US", "French" => "fr"} + } + Commandline.new([], options).csv2android + + assert File.exist?("./values-en-rUS/strings.xml") + assert File.exist?("./values-fr/strings.xml") + + # clean up + system("rm -rf ./values-en-rUS/") + system("rm -rf ./values-fr/") + end + def test_csv2android_with_output_dir options = { :filename => "test/data/test_data_multiple_langs.csv",