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 +8 -8
- data/lib/babelish/csv2android.rb +4 -2
- data/lib/babelish/version.rb +1 -1
- data/test/babelish/test_csv2android.rb +27 -6
- data/test/data/test_data_fr_with_comments.xml +9 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWFiZDM4NDg3Zjg2NGRjYThiYmJmZjZkNjY2NDM0MzgxMjFhZmVmNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDkxZmQ1ZjY1ZDE3OWQwN2YzYzJiMzkyYTI1ODhmMWUwYjU3YTdhYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWQ0ZTVlOTkzM2ZmNDI1ODJjNWUwZGM4YzkyNjZmOTQ1Y2M2ODEwZTlhMDE0
|
10
|
+
YTM0ZjU4OTQzNWU3MDdiYTQwMWViMWE0M2E0MjcyZDk3MzczMGM4MThkOGNi
|
11
|
+
YWQ3NTRmMzMyOTIyYWJjMzViZGZiMGU0NzZkMjgzOWEzOGNkNGI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDEwNTU2ZGQ0YTA4NWI5NmEzMTdkMWVhN2RjMDI2YjkwN2FiODAwM2EyZjcz
|
14
|
+
MmVmOGYwM2NjYmY0ZDA5YTUzOGY3YTM0YjM4MDc5MTY0NDU5YjYyN2FhOTVh
|
15
|
+
ZWRlNTY1NTkwYmMwOWIyMDA3MDQyMjMwMmZkZjk5N2NiYWFjMTM=
|
data/lib/babelish/csv2android.rb
CHANGED
@@ -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
|
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
|
-
|
38
|
+
comment = @comments[key]
|
39
|
+
output += get_row_format(key, value, comment)
|
38
40
|
end
|
39
41
|
output += "</resources>\n"
|
40
42
|
end
|
data/lib/babelish/version.rb
CHANGED
@@ -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,
|
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 =
|
28
|
-
converter = Babelish::CSV2Android.new(
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
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
|
+
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:
|