babelish 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmI5Mjk2MTU1YmY5NTMyY2Q1ZjAxNzQxMDQ3ZWEzZTVlNTcxZTliMw==
4
+ YWFiZDM4NDg3Zjg2NGRjYThiYmJmZjZkNjY2NDM0MzgxMjFhZmVmNg==
5
5
  data.tar.gz: !binary |-
6
- M2MyNjU2ZmIxYzNjZWI2OWJhOTAxNzhhNDczYmE5ZDJlZjA1YTE0Yg==
6
+ MDkxZmQ1ZjY1ZDE3OWQwN2YzYzJiMzkyYTI1ODhmMWUwYjU3YTdhYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- M2FiOTQ3MTZlZDYxNzkyNWViNGNkNGYyNDg3ZDZmZWQxOTJkYzliM2M5ZDA0
10
- NTAxMThkZGZhM2U2MWY5OTJiNWIzYmI5Nzk1N2ZhMGQzOWZkYWM3Mjc2YzYy
11
- ZjI1NjY2MjEzZGI5ZTg1N2ZhZjU2ODIyNjExMDU0ZDQ5Yjk0ZjE=
9
+ YWQ0ZTVlOTkzM2ZmNDI1ODJjNWUwZGM4YzkyNjZmOTQ1Y2M2ODEwZTlhMDE0
10
+ YTM0ZjU4OTQzNWU3MDdiYTQwMWViMWE0M2E0MjcyZDk3MzczMGM4MThkOGNi
11
+ YWQ3NTRmMzMyOTIyYWJjMzViZGZiMGU0NzZkMjgzOWEzOGNkNGI=
12
12
  data.tar.gz: !binary |-
13
- MDJhMWQxY2Q2ZTA0MTVkZmJiYTVjMzUyNjBlNTVhNGViMTFiNTI5ZDE1Y2Vm
14
- NTkyNGU5YTE5Mjk4NjI4M2I5ZjMzNTY4ZDNkM2E2NmU1YmQ5NWQxNGQ3OWFh
15
- NzY2OGVkYjhhZjczOTUyYWY1ZTEwNTM2NmU0ZGY3NWM4MjY0Njc=
13
+ ZDEwNTU2ZGQ0YTA4NWI5NmEzMTdkMWVhN2RjMDI2YjkwN2FiODAwM2EyZjcz
14
+ MmVmOGYwM2NjYmY0ZDA5YTUzOGY3YTM0YjM4MDc5MTY0NDU5YjYyN2FhOTVh
15
+ ZWRlNTY1NTkwYmMwOWIyMDA3MDQyMjMwMmZkZjk5N2NiYWFjMTM=
@@ -25,7 +25,8 @@ module Babelish
25
25
  end
26
26
 
27
27
  def get_row_format(row_key, row_value, comment = nil, indentation = 0)
28
- "\t<string name=\"#{row_key}\">#{row_value}</string>\n"
28
+ entry = comment.to_s.empty? ? "" : "\n\t<!-- #{comment} -->\n"
29
+ entry + "\t<string name=\"#{row_key}\">#{row_value}</string>\n"
29
30
  end
30
31
 
31
32
  def hash_to_output(content = {})
@@ -34,7 +35,8 @@ module Babelish
34
35
  output += "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
35
36
  output += "<resources>\n"
36
37
  content.each do |key, value|
37
- output += get_row_format(key, value)
38
+ comment = @comments[key]
39
+ output += get_row_format(key, value, comment)
38
40
  end
39
41
  output += "</resources>\n"
40
42
  end
@@ -1,3 +1,3 @@
1
1
  module Babelish
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -3,7 +3,7 @@ class TestCSV2Android < Test::Unit::TestCase
3
3
 
4
4
  def test_converting_csv_to_xml
5
5
  csv_file = "test/data/test_data.csv"
6
- converter = Babelish::CSV2Android.new(csv_file, 'English' => "en")
6
+ converter = Babelish::CSV2Android.new(csv_file, "English" => "en")
7
7
  converter.convert
8
8
  assert File.exist?("values-en/strings.xml"), "the ouptut file does not exist"
9
9
 
@@ -24,15 +24,36 @@ class TestCSV2Android < Test::Unit::TestCase
24
24
 
25
25
  def test_converting_csv_to_dotstrings_one_output_option
26
26
  csv_file = "test/data/test_data.csv"
27
- single_file = 'myApp.xml'
28
- converter = Babelish::CSV2Android.new(csv_file,
29
- {'English' => "en"},
30
- :output_basename => 'myApp',
31
- :ignore_lang_path => true)
27
+ single_file = "myApp.xml"
28
+ converter = Babelish::CSV2Android.new(
29
+ csv_file,
30
+ { "English" => "en" },
31
+ :output_basename => "myApp",
32
+ :ignore_lang_path => true
33
+ )
32
34
  converter.convert
33
35
  assert File.exist?(single_file), "the ouptut file does not exist"
34
36
 
35
37
  # clean up
36
38
  system("rm -rf ./" + single_file)
37
39
  end
40
+
41
+ def test_converting_with_comments
42
+ csv_file = "test/data/test_data_with_comments.csv"
43
+ french_file = "values-fr/strings.xml"
44
+ expected_output = File.read("test/data/test_data_fr_with_comments.xml")
45
+ converter = Babelish::CSV2Android.new(
46
+ csv_file,
47
+ { "French" => "fr" },
48
+ :default_lang => "English",
49
+ :comments_column => 5
50
+ )
51
+ converter.convert
52
+ assert File.exist?(french_file), "the ouptut file does not exist"
53
+ result = File.read(french_file)
54
+ assert_equal expected_output, result
55
+
56
+ # clean up
57
+ system("rm -rf values-fr")
58
+ end
38
59
  end
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <resources>
3
+
4
+ <!-- this is a greeting string -->
5
+ <string name="GREETINGS">Salut</string>
6
+
7
+ <!-- this is another example -->
8
+ <string name="ANOTHER_STRING">testEN</string>
9
+ </resources>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: babelish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - François Benaiteau
@@ -204,6 +204,7 @@ files:
204
204
  - test/data/test_data.csv
205
205
  - test/data/test_data.strings
206
206
  - test/data/test_data_fr_with_comments.strings
207
+ - test/data/test_data_fr_with_comments.xml
207
208
  - test/data/test_data_multiple_langs.csv
208
209
  - test/data/test_data_with_comments.csv
209
210
  - test/data/test_data_with_percent.csv
@@ -243,3 +244,4 @@ signing_key:
243
244
  specification_version: 4
244
245
  summary: CSV converter for localization files
245
246
  test_files: []
247
+ has_rdoc: