babelish 0.6.0 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -0
  3. data/lib/babelish.rb +1 -0
  4. data/lib/babelish/google_doc.rb +5 -2
  5. data/lib/babelish/keys.rb +6 -0
  6. data/lib/babelish/version.rb +1 -1
  7. metadata +5 -59
  8. data/.babelish.sample +0 -35
  9. data/.gitignore +0 -31
  10. data/.hound.yml +0 -4
  11. data/.travis.yml +0 -15
  12. data/CONTRIBUTING.md +0 -12
  13. data/Dockerfile +0 -6
  14. data/Gemfile +0 -8
  15. data/Rakefile +0 -17
  16. data/babelish.gemspec +0 -42
  17. data/test/babelish/commands/test_command_android2csv.rb +0 -60
  18. data/test/babelish/commands/test_command_csv2android.rb +0 -50
  19. data/test/babelish/commands/test_command_csv2strings.rb +0 -139
  20. data/test/babelish/commands/test_command_strings2csv.rb +0 -110
  21. data/test/babelish/test_android2csv.rb +0 -53
  22. data/test/babelish/test_base2csv.rb +0 -43
  23. data/test/babelish/test_bins.rb +0 -32
  24. data/test/babelish/test_commandline.rb +0 -127
  25. data/test/babelish/test_csv2android.rb +0 -72
  26. data/test/babelish/test_csv2base.rb +0 -44
  27. data/test/babelish/test_csv2json.rb +0 -27
  28. data/test/babelish/test_csv2php.rb +0 -27
  29. data/test/babelish/test_csv2strings.rb +0 -154
  30. data/test/babelish/test_fastlane.rb +0 -19
  31. data/test/babelish/test_json2csv.rb +0 -34
  32. data/test/babelish/test_php2csv.rb +0 -73
  33. data/test/babelish/test_strings2csv.rb +0 -147
  34. data/test/babelish/test_xcode_macros.rb +0 -112
  35. data/test/data/android-en.xml +0 -9
  36. data/test/data/android-fr.xml +0 -9
  37. data/test/data/android.xml +0 -9
  38. data/test/data/android_special_chars.csv +0 -8
  39. data/test/data/android_special_chars.xml +0 -12
  40. data/test/data/android_special_chars_test_result.xml +0 -10
  41. data/test/data/genstrings.strings +0 -0
  42. data/test/data/json.json +0 -6
  43. data/test/data/php_lang.php +0 -8
  44. data/test/data/test_comments.strings +0 -2
  45. data/test/data/test_data.csv +0 -3
  46. data/test/data/test_data.strings +0 -2
  47. data/test/data/test_data_fr_with_comments.strings +0 -6
  48. data/test/data/test_data_fr_with_comments.xml +0 -9
  49. data/test/data/test_data_multiple_langs.csv +0 -3
  50. data/test/data/test_data_with_comments.csv +0 -3
  51. data/test/data/test_data_with_percent.csv +0 -3
  52. data/test/data/test_data_with_percent_space.csv +0 -4
  53. data/test/data/test_data_with_semicolon.csv +0 -3
  54. data/test/data/test_data_with_spaces.csv +0 -3
  55. data/test/data/test_en.strings +0 -2
  56. data/test/data/test_fr.strings +0 -2
  57. data/test/data/test_space.strings +0 -10
  58. data/test/data/test_utf16.strings +0 -0
  59. data/test/data/test_with_nil.csv +0 -3
  60. data/test/data/test_with_nil.strings +0 -4
  61. data/test/data/xcode_empty.strings +0 -7
  62. data/test/test_helper.rb +0 -17
@@ -1,147 +0,0 @@
1
- require 'test_helper'
2
- class TestStrings2CSV < Test::Unit::TestCase
3
-
4
- def test_parse_dotstrings_line_with_good_string
5
- input = String.new(<<-EOS)
6
- "MY_CONSTANT" = "This is ok";
7
- EOS
8
- expected_output = ["MY_CONSTANT","This is ok"]
9
-
10
- output = Babelish::Strings2CSV.new.parse_dotstrings_line input
11
- assert_equal expected_output, output
12
- end
13
-
14
- def test_parse_dotstrings_line_with_single_quote
15
- input = String.new(<<-EOS)
16
- "MY_CONSTANT" = "This 'is' ok";
17
- EOS
18
- expected_output = ["MY_CONSTANT","This 'is' ok"]
19
-
20
- output = Babelish::Strings2CSV.new.parse_dotstrings_line input
21
- assert_equal expected_output, output
22
- end
23
-
24
- def test_parse_dotstrings_line_with_double_quotes
25
- input = String.new(<<-EOS)
26
- "MY_CONSTANT" = "This "is" ok";
27
- EOS
28
- expected_output = ["MY_CONSTANT","This \"is\" ok"]
29
-
30
- output = Babelish::Strings2CSV.new.parse_dotstrings_line input
31
- assert_equal expected_output, output
32
- end
33
-
34
- def test_parse_dotstrings_line_with_wrong_string
35
- input = String.new(<<-EOS)
36
- "MY_CONSTANT" = "wrong syntax"
37
- EOS
38
-
39
- output = Babelish::Strings2CSV.new.parse_dotstrings_line input
40
- assert_nil output, "output should be nil with wrong syntax"
41
- end
42
-
43
- def test_parse_dotstrings_line_with_comment
44
- input = String.new(<<-EOS)
45
- /* Class = "IBUIButton"; normalTitle = "Wibble"; ObjectID = "xxx-xx-123"; */
46
- EOS
47
-
48
- output = Babelish::Strings2CSV.new.parse_dotstrings_line input
49
- assert_nil output, "output should be nil with comment"
50
- end
51
-
52
- def test_parse_comment
53
- comment= "/* this is a comment */"
54
- output = Babelish::Strings2CSV.new.parse_comment_line comment
55
- assert_equal "this is a comment", output
56
- end
57
-
58
- def test_load_strings_with_wrong_file
59
- assert_raise(Errno::ENOENT) do
60
- output = Babelish::Strings2CSV.new.load_strings "file that does not exist.strings"
61
- end
62
- end
63
-
64
- def test_load_strings
65
- expected_output = [{"ERROR_HANDLER_WARNING_DISMISS" => "OK", "ANOTHER_STRING" => "hello"}, {}]
66
- output = Babelish::Strings2CSV.new.load_strings "test/data/test_data.strings"
67
- assert_equal expected_output, output
68
- end
69
-
70
- def test_load_strings_with_spaces
71
- expected_output = [{ "name" => "definition",
72
- "name1" => "definition1",
73
- "name2" => "definition2",
74
- "name3" => "definition3",
75
- "name4" => "definition4",
76
- "this is a name" => "a definition"
77
- }, {}]
78
- output = Babelish::Strings2CSV.new.load_strings "test/data/test_space.strings"
79
- assert_equal expected_output, output
80
- end
81
-
82
- def test_load_strings_with_comments
83
- expected_output = [{"MY_CONSTANT"=>"This 'is' ok"}, {"MY_CONSTANT"=> "this is a comment"}]
84
-
85
- output = Babelish::Strings2CSV.new.load_strings "test/data/test_comments.strings"
86
- assert_equal expected_output, output
87
- end
88
-
89
- def test_load_strings_with_empty_lines
90
- assert_nothing_raised do
91
- output = Babelish::Strings2CSV.new.load_strings "test/data/test_with_nil.strings"
92
- end
93
- end
94
-
95
- def test_load_strings_with_empty_lines_and_comments
96
- assert_nothing_raised do
97
- output = Babelish::Strings2CSV.new.load_strings "test/data/xcode_empty.strings"
98
- end
99
- end
100
-
101
- def test_load_strings_with_genstrings_file
102
- assert_nothing_raised do
103
- output = Babelish::Strings2CSV.new.load_strings "test/data/genstrings.strings"
104
- end
105
- end
106
-
107
- def test_dotstrings_to_csv
108
- converter = Babelish::Strings2CSV.new(:filenames => ["test/data/test_data.strings"])
109
- keys, strings = converter.convert(false)
110
- assert_equal ["ERROR_HANDLER_WARNING_DISMISS", "ANOTHER_STRING"], keys
111
-
112
- end
113
-
114
- def test_create_csv_file
115
- keys = ["ERROR_HANDLER_WARNING_DISMISS", "ANOTHER_STRING"]
116
- filename = "test_data"
117
- strings = {filename => {"ERROR_HANDLER_WARNING_DISMISS" => "OK", "ANOTHER_STRING" => "hello"}}
118
-
119
- converter = Babelish::Strings2CSV.new(:headers => %w{variables english}, :filenames => [filename])
120
-
121
- converter.send :create_csv_file, keys, strings
122
- assert File.exist?(converter.csv_filename)
123
-
124
- # clean up
125
- system("rm -rf ./" + converter.csv_filename)
126
- end
127
-
128
- def test_initialize
129
- csv_filename = "file.csv"
130
- filenames = %w{french.strings english.strings}
131
- headers = %w{constants french english}
132
- converter = Babelish::Strings2CSV.new({
133
- :csv_filename => csv_filename,
134
- :headers => headers,
135
- :filenames => filenames })
136
-
137
- assert_equal csv_filename, converter.csv_filename
138
- assert_equal headers, converter.headers
139
- assert_equal filenames, converter.filenames
140
- end
141
-
142
- def test_initialize_with_default_values
143
- converter = Babelish::Strings2CSV.new
144
- assert_not_nil converter.csv_filename
145
- end
146
-
147
- end
@@ -1,112 +0,0 @@
1
- require "test_helper"
2
- class TestXcodeMacros < Test::Unit::TestCase
3
- def test_process
4
- keys = ["login.title", "login.button"]
5
- table = "Localizable"
6
- xcode_macros = Babelish::XcodeMacros.new
7
- content = xcode_macros.process(table, keys)
8
- expected_output = String.new(<<-EOS)
9
- #define LS_LOGIN_TITLE NSLocalizedStringFromTable(@"login.title",@"Localizable",@"")
10
- #define LS_LOGIN_BUTTON NSLocalizedStringFromTable(@"login.button",@"Localizable",@"")
11
- EOS
12
- assert_equal expected_output, content
13
- end
14
-
15
- def test_write_macros_class_method
16
- keys = ["login.title", "login.button"]
17
- table = "Localizable"
18
- Babelish::XcodeMacros.write_macros("Babelish.h", table, keys)
19
- expected_output = String.new(<<-EOS)
20
- //
21
- // Babelish.h
22
- //
23
- // This file was generated by Babelish
24
- //
25
- // https://github.com/netbe/babelish
26
- //
27
- #define LS_LOGIN_TITLE NSLocalizedStringFromTable(@"login.title",@"Localizable",@"")
28
- #define LS_LOGIN_BUTTON NSLocalizedStringFromTable(@"login.button",@"Localizable",@"")
29
- EOS
30
- assert File.exist?("Babelish.h")
31
- result = File.read("Babelish.h")
32
- assert_equal expected_output, result
33
- # clean up
34
- system("rm -f ./Babelish.h")
35
- end
36
-
37
- def test_write_macros_process
38
- keys = ["login.title", "login.button"]
39
- table = "Localizable"
40
- macros = Babelish::XcodeMacros.new
41
- macros.process(table, keys)
42
- macros.write_content("Babelish.h")
43
- expected_output = String.new(<<-EOS)
44
- //
45
- // Babelish.h
46
- //
47
- // This file was generated by Babelish
48
- //
49
- // https://github.com/netbe/babelish
50
- //
51
- #define LS_LOGIN_TITLE NSLocalizedStringFromTable(@"login.title",@"Localizable",@"")
52
- #define LS_LOGIN_BUTTON NSLocalizedStringFromTable(@"login.button",@"Localizable",@"")
53
- EOS
54
- assert File.exist?("Babelish.h")
55
- result = File.read("Babelish.h")
56
- assert_equal expected_output, result
57
- # clean up
58
- system("rm -f ./Babelish.h")
59
- end
60
-
61
- def test_write_macros_process_with_special_characters
62
- keys = ["%d blabla", "login!", "HEY!!"]
63
- table = "Localizable"
64
- macros = Babelish::XcodeMacros.new
65
- macros.process(table, keys)
66
- macros.write_content("Babelish.h")
67
- expected_output = String.new(<<-EOS)
68
- //
69
- // Babelish.h
70
- //
71
- // This file was generated by Babelish
72
- //
73
- // https://github.com/netbe/babelish
74
- //
75
- #define LS_DBLABLA NSLocalizedStringFromTable(@"%d blabla",@"Localizable",@"")
76
- #define LS_LOGIN NSLocalizedStringFromTable(@"login!",@"Localizable",@"")
77
- #define LS_HEY NSLocalizedStringFromTable(@"HEY!!",@"Localizable",@"")
78
- EOS
79
- assert File.exist?("Babelish.h")
80
- result = File.read("Babelish.h")
81
- assert_equal expected_output, result
82
- # clean up
83
- system("rm -f ./Babelish.h")
84
- end
85
-
86
- def test_write_macros_with_comments_process
87
- keys = ["login.title", "login.button"]
88
- table = "Localizable"
89
- comments = {"login.title" => "this is the login screen title", "login.button" => nil}
90
- macros = Babelish::XcodeMacros.new
91
- macros.process(table, keys, comments)
92
- macros.write_content("Babelish.h")
93
- expected_output = String.new(<<-EOS)
94
- //
95
- // Babelish.h
96
- //
97
- // This file was generated by Babelish
98
- //
99
- // https://github.com/netbe/babelish
100
- //
101
- #define LS_LOGIN_TITLE NSLocalizedStringFromTable(@"login.title",@"Localizable",@"this is the login screen title")
102
- #define LS_LOGIN_BUTTON NSLocalizedStringFromTable(@"login.button",@"Localizable",@"")
103
- EOS
104
- assert File.exist?("Babelish.h")
105
- result = File.read("Babelish.h")
106
- assert_equal expected_output, result
107
- # clean up
108
- system("rm -f ./Babelish.h")
109
- end
110
-
111
-
112
- end
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <resources>
3
-
4
- <string name="app_name">android2csv</string>
5
- <string name="action_greetings">Hello</string>
6
- <string name="ANOTHER_STRING">testEN</string>
7
- <string name="empty"></string>
8
-
9
- </resources>
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <resources>
3
-
4
- <string name="app_name">android2csv</string>
5
- <string name="action_greetings">Bonjour</string>
6
- <string name="ANOTHER_STRING">testFR</string>
7
- <string name="empty"></string>
8
-
9
- </resources>
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <resources>
3
-
4
- <string name="app_name">android2csv</string>
5
- <string name="action_greetings">Hello</string>
6
- <string name="ANOTHER_STRING">testEN</string>
7
- <string name="empty"></string>
8
-
9
- </resources>
@@ -1,8 +0,0 @@
1
- variables,german
2
- good_example_1,This\'ll work
3
- good_example_2,"This is a \""good string\""."
4
- good_example_3,"""This'll also work"""
5
- welcome_messages_1,"Hello, %1$s! You have %2$d new messages."
6
- welcome_messages_2,"Hello, %1$s! You have &lt;b&gt;%2$d new messages&lt;/b&gt;."
7
- ANOTHER_STRING,"text <b>with</b> html and \' special # chars ` ´ !""§$%/()==?{[]}"
8
- title,"Title of &lt;a href=""asd""&gt;File&lt;/a&gt;"
@@ -1,12 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <resources>
3
-
4
- <string name="good_example_1">This\'ll work</string>
5
- <string name="good_example_2">This is a \"good string\".</string>
6
- <string name="good_example_3">"This'll also work"</string>
7
- <string name="welcome_messages_1">Hello, %1$s! You have %2$d new messages.</string>
8
- <string name="welcome_messages_2">Hello, %1$s! You have &lt;b>%2$d new messages&lt;/b>.</string>
9
- <string name="ANOTHER_STRING">text <b>with</b> html and \' special # chars ` ´ !"§$%/()==?{[]}</string>
10
- <string name="title">Title of &lt;a href="asd">File&lt;/a></string>
11
-
12
- </resources>
@@ -1,10 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <resources>
3
- <string name="good_example_1">This\'ll work</string>
4
- <string name="good_example_2">This is a \"good string\".</string>
5
- <string name="good_example_3">"This'll also work"</string>
6
- <string name="welcome_messages_1">Hello, %1$s! You have %2$d new messages.</string>
7
- <string name="welcome_messages_2">Hello, %1$s! You have &lt;b&gt;%2$d new messages&lt;/b&gt;.</string>
8
- <string name="ANOTHER_STRING">text <b>with</b> html and \' special # chars ` ´ !\"§$%/()==?{[]}</string>
9
- <string name="title">Title of &lt;a href=\"asd\"&gt;File&lt;/a&gt;</string>
10
- </resources>
Binary file
@@ -1,6 +0,0 @@
1
- {
2
- "app_name": "json2csv",
3
- "action_greetings": "hello",
4
- "ANOTHER_STRING": "testEN",
5
- "empty": ""
6
- }
@@ -1,8 +0,0 @@
1
- <?php
2
-
3
- $lang['app_name'] = "php2csv";
4
- $lang['action_greetings'] = "Hello";
5
- $lang['ANOTHER_STRING'] = "testEN";
6
- $lang['empty'] = "";
7
-
8
- ?>
@@ -1,2 +0,0 @@
1
- /* this is a comment */
2
- "MY_CONSTANT" = "This 'is' ok";
@@ -1,3 +0,0 @@
1
- variables,English
2
- ERROR_HANDLER_WARNING_DISMISS,OK
3
- ANOTHER_STRING,hello
@@ -1,2 +0,0 @@
1
- "ERROR_HANDLER_WARNING_DISMISS" = "OK";
2
- "ANOTHER_STRING" = "hello";
@@ -1,6 +0,0 @@
1
-
2
- /* this is a greeting string */
3
- "GREETINGS" = "Salut";
4
-
5
- /* this is another example */
6
- "ANOTHER_STRING" = "testEN";
@@ -1,9 +0,0 @@
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>
@@ -1,3 +0,0 @@
1
- variables,English,German,French,Spanish
2
- GREETINGS,Hello,Hallo,Salut,Buenos dias
3
- ANOTHER_STRING,testEN,,,
@@ -1,3 +0,0 @@
1
- variables,English,German,French,Spanish,Comments
2
- GREETINGS,Hello,Hallo,Salut,Buenos dias,this is a greeting string
3
- ANOTHER_STRING,testEN,,,,this is another example
@@ -1,3 +0,0 @@
1
- variables,English
2
- GREETINGS,hello_%@
3
- ANOTHER_STRING,hello
@@ -1,4 +0,0 @@
1
- variables,English
2
- GREETINGS,you have %d points
3
- ANOTHER_STRING,this is a string with 10% of juice
4
- ANOTHER_EXAMPLE,tu as fait 10% d'efforts
@@ -1,3 +0,0 @@
1
- variables;English
2
- ERROR_HANDLER_WARNING_DISMISS;OK
3
- ANOTHER_STRING;hello
@@ -1,3 +0,0 @@
1
- variables,English
2
- GREETINGS ,hello
3
- ANOTHER_STRING, my other string with space at begin
@@ -1,2 +0,0 @@
1
- "GREETINGS" = "Hello";
2
- "ANOTHER_STRING" = "testEN";
@@ -1,2 +0,0 @@
1
- "GREETINGS" = "Bonjour";
2
- "ANOTHER_STRING" = "testFR";
@@ -1,10 +0,0 @@
1
- "name"= "definition";
2
- "name1"="definition1";
3
- "name2" = "definition2";
4
- "name3" = "definition3" ;
5
- "name4" = "definition4";
6
- "this is a name"="a definition";
7
- wrong format "should be ignored" = "really" ;
8
- "should be ignored"wrong format = "really" ;
9
- "should be ignored"= "really" dd;
10
- "should be ignored"=aa "really";
Binary file
@@ -1,3 +0,0 @@
1
- Variables,test/data/test_with_nil.strings
2
- GREETINGS,Hello
3
- ANOTHER_STRING,testEN
@@ -1,4 +0,0 @@
1
- "GREETINGS" = "Hello";
2
-
3
- "ANOTHER_STRING" = "testEN";
4
-
@@ -1,7 +0,0 @@
1
- /*
2
- Localized.strings
3
- testLocalization
4
-
5
- Created by François Benaiteau on 14/04/14.
6
- Copyright (c) 2014 SinnerSchrader Mobile. All rights reserved.
7
- */