babelish 0.5.6 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/lib/babelish.rb +1 -0
- data/lib/babelish/csv2android.rb +2 -1
- data/lib/babelish/google_doc.rb +8 -4
- data/lib/babelish/keys.rb +6 -0
- data/lib/babelish/version.rb +1 -1
- metadata +10 -65
- data/.babelish.sample +0 -35
- data/.gitignore +0 -31
- data/.hound.yml +0 -4
- data/.travis.yml +0 -15
- data/CONTRIBUTING.md +0 -12
- data/Dockerfile +0 -6
- data/Gemfile +0 -8
- data/Rakefile +0 -17
- data/babelish.gemspec +0 -42
- data/test/babelish/commands/test_command_android2csv.rb +0 -60
- data/test/babelish/commands/test_command_csv2android.rb +0 -35
- data/test/babelish/commands/test_command_csv2strings.rb +0 -139
- data/test/babelish/commands/test_command_strings2csv.rb +0 -110
- data/test/babelish/test_android2csv.rb +0 -53
- data/test/babelish/test_base2csv.rb +0 -43
- data/test/babelish/test_bins.rb +0 -32
- data/test/babelish/test_commandline.rb +0 -127
- data/test/babelish/test_csv2android.rb +0 -72
- data/test/babelish/test_csv2base.rb +0 -44
- data/test/babelish/test_csv2json.rb +0 -27
- data/test/babelish/test_csv2php.rb +0 -27
- data/test/babelish/test_csv2strings.rb +0 -154
- data/test/babelish/test_fastlane.rb +0 -19
- data/test/babelish/test_json2csv.rb +0 -34
- data/test/babelish/test_php2csv.rb +0 -73
- data/test/babelish/test_strings2csv.rb +0 -147
- data/test/babelish/test_xcode_macros.rb +0 -112
- data/test/data/android-en.xml +0 -9
- data/test/data/android-fr.xml +0 -9
- data/test/data/android.xml +0 -9
- data/test/data/android_special_chars.csv +0 -8
- data/test/data/android_special_chars.xml +0 -12
- data/test/data/android_special_chars_test_result.xml +0 -10
- data/test/data/genstrings.strings +0 -0
- data/test/data/json.json +0 -6
- data/test/data/php_lang.php +0 -8
- data/test/data/test_comments.strings +0 -2
- data/test/data/test_data.csv +0 -3
- data/test/data/test_data.strings +0 -2
- data/test/data/test_data_fr_with_comments.strings +0 -6
- data/test/data/test_data_fr_with_comments.xml +0 -9
- data/test/data/test_data_multiple_langs.csv +0 -3
- data/test/data/test_data_with_comments.csv +0 -3
- data/test/data/test_data_with_percent.csv +0 -3
- data/test/data/test_data_with_percent_space.csv +0 -4
- data/test/data/test_data_with_semicolon.csv +0 -3
- data/test/data/test_data_with_spaces.csv +0 -3
- data/test/data/test_en.strings +0 -2
- data/test/data/test_fr.strings +0 -2
- data/test/data/test_space.strings +0 -10
- data/test/data/test_utf16.strings +0 -0
- data/test/data/test_with_nil.csv +0 -3
- data/test/data/test_with_nil.strings +0 -4
- data/test/data/xcode_empty.strings +0 -7
- 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
|
data/test/data/android-en.xml
DELETED
data/test/data/android-fr.xml
DELETED
data/test/data/android.xml
DELETED
@@ -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 <b>%2$d new messages</b>."
|
7
|
-
ANOTHER_STRING,"text <b>with</b> html and \' special # chars ` ´ !""§$%/()==?{[]}"
|
8
|
-
title,"Title of <a href=""asd"">File</a>"
|
@@ -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 <b>%2$d new messages</b>.</string>
|
9
|
-
<string name="ANOTHER_STRING">text <b>with</b> html and \' special # chars ` ´ !"§$%/()==?{[]}</string>
|
10
|
-
<string name="title">Title of <a href="asd">File</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 <b>%2$d new messages</b>.</string>
|
8
|
-
<string name="ANOTHER_STRING">text <b>with</b> html and \' special # chars ` ´ !\"§$%/()==?{[]}</string>
|
9
|
-
<string name="title">Title of <a href=\"asd\">File</a></string>
|
10
|
-
</resources>
|
Binary file
|
data/test/data/json.json
DELETED
data/test/data/php_lang.php
DELETED
data/test/data/test_data.csv
DELETED
data/test/data/test_data.strings
DELETED
data/test/data/test_en.strings
DELETED
data/test/data/test_fr.strings
DELETED
@@ -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
|
data/test/data/test_with_nil.csv
DELETED