twine 0.7.0 → 0.8.0
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 +12 -0
- data/lib/twine.rb +21 -0
- data/lib/twine/cli.rb +68 -91
- data/lib/twine/formatters/abstract.rb +133 -82
- data/lib/twine/formatters/android.rb +49 -67
- data/lib/twine/formatters/apple.rb +33 -47
- data/lib/twine/formatters/django.rb +38 -48
- data/lib/twine/formatters/flash.rb +25 -40
- data/lib/twine/formatters/gettext.rb +37 -44
- data/lib/twine/formatters/jquery.rb +31 -33
- data/lib/twine/formatters/tizen.rb +38 -55
- data/lib/twine/output_processor.rb +57 -0
- data/lib/twine/placeholders.rb +54 -0
- data/lib/twine/runner.rb +78 -115
- data/lib/twine/stringsfile.rb +83 -60
- data/lib/twine/version.rb +1 -1
- data/test/command_test_case.rb +12 -0
- data/test/fixtures/consume_loc_drop.zip +0 -0
- data/test/fixtures/formatter_android.xml +15 -0
- data/test/fixtures/formatter_apple.strings +20 -0
- data/test/fixtures/formatter_django.po +28 -0
- data/test/fixtures/formatter_flash.properties +15 -0
- data/test/fixtures/formatter_gettext.po +26 -0
- data/test/fixtures/formatter_jquery.json +7 -0
- data/test/fixtures/formatter_tizen.xml +15 -0
- data/test/fixtures/gettext_multiline.po +10 -0
- data/test/fixtures/twine_accent_values.txt +13 -0
- data/test/test_abstract_formatter.rb +152 -0
- data/test/test_cli.rb +288 -0
- data/test/test_consume_loc_drop.rb +27 -0
- data/test/test_consume_string_file.rb +53 -0
- data/test/test_formatters.rb +236 -0
- data/test/test_generate_all_string_files.rb +44 -0
- data/test/test_generate_loc_drop.rb +44 -0
- data/test/test_generate_string_file.rb +51 -0
- data/test/test_output_processor.rb +85 -0
- data/test/test_placeholders.rb +86 -0
- data/test/test_strings_file.rb +58 -0
- data/test/test_strings_row.rb +47 -0
- data/test/test_validate_strings_file.rb +55 -0
- data/test/twine_file_dsl.rb +46 -0
- data/test/twine_test_case.rb +44 -0
- metadata +80 -37
- data/test/fixtures/en-1.json +0 -5
- data/test/fixtures/en-1.po +0 -16
- data/test/fixtures/en-1.strings +0 -10
- data/test/fixtures/en-2.po +0 -23
- data/test/fixtures/en-3.xml +0 -8
- data/test/fixtures/fr-1.xml +0 -10
- data/test/fixtures/strings-1.txt +0 -17
- data/test/fixtures/strings-2.txt +0 -5
- data/test/fixtures/strings-3.txt +0 -5
- data/test/fixtures/test-json-line-breaks/consumed.txt +0 -5
- data/test/fixtures/test-json-line-breaks/generated.json +0 -3
- data/test/fixtures/test-json-line-breaks/line-breaks.json +0 -3
- data/test/fixtures/test-json-line-breaks/line-breaks.txt +0 -4
- data/test/fixtures/test-output-1.txt +0 -12
- data/test/fixtures/test-output-10.txt +0 -9
- data/test/fixtures/test-output-11.txt +0 -9
- data/test/fixtures/test-output-12.txt +0 -12
- data/test/fixtures/test-output-2.txt +0 -12
- data/test/fixtures/test-output-3.txt +0 -18
- data/test/fixtures/test-output-4.txt +0 -21
- data/test/fixtures/test-output-5.txt +0 -4
- data/test/fixtures/test-output-6.txt +0 -10
- data/test/fixtures/test-output-7.txt +0 -16
- data/test/fixtures/test-output-8.txt +0 -9
- data/test/fixtures/test-output-9.txt +0 -21
- data/test/twine_test.rb +0 -134
@@ -1,12 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<!-- Tizen Strings File -->
|
3
|
-
<!-- Generated by Twine <%= Twine::VERSION %> -->
|
4
|
-
<!-- Language: fr -->
|
5
|
-
<string_table Bversion="2.0.0.201311071819" Dversion="20120315">
|
6
|
-
<!-- SECTION: My Strings -->
|
7
|
-
<!-- This is a comment -->
|
8
|
-
<text id="IDS_KEY1">key1-french</text>
|
9
|
-
<text id="IDS_KEY2">key2-french</text>
|
10
|
-
<text id="IDS_KEY3">key3-english</text>
|
11
|
-
<text id="IDS_KEY4">key4-english</text>
|
12
|
-
</string_table>
|
@@ -1,18 +0,0 @@
|
|
1
|
-
[[My Strings]]
|
2
|
-
[key1]
|
3
|
-
en = key1-english
|
4
|
-
tags = tag1
|
5
|
-
comment = This is a comment
|
6
|
-
es = key1-spanish
|
7
|
-
fr = key1-french
|
8
|
-
[key2]
|
9
|
-
en = key2-english
|
10
|
-
tags = tag2
|
11
|
-
fr = key2-french
|
12
|
-
[key3]
|
13
|
-
en = key3-english
|
14
|
-
tags = tag1,tag2
|
15
|
-
es = key3-spanish
|
16
|
-
fr = key3-french
|
17
|
-
[key4]
|
18
|
-
en = key4-english
|
@@ -1,21 +0,0 @@
|
|
1
|
-
[[Uncategorized]]
|
2
|
-
[key5]
|
3
|
-
en = A new string
|
4
|
-
|
5
|
-
[[My Strings]]
|
6
|
-
[key1]
|
7
|
-
en = key1-english
|
8
|
-
tags = tag1
|
9
|
-
comment = This is a comment
|
10
|
-
es = key1-spanish
|
11
|
-
fr = key1-french
|
12
|
-
[key2]
|
13
|
-
en = key2-english
|
14
|
-
tags = tag2
|
15
|
-
fr = key2-french
|
16
|
-
[key3]
|
17
|
-
en = key3-english
|
18
|
-
tags = tag1,tag2
|
19
|
-
es = key3-spanish
|
20
|
-
[key4]
|
21
|
-
en = key4-english
|
@@ -1,16 +0,0 @@
|
|
1
|
-
msgid ""
|
2
|
-
msgstr ""
|
3
|
-
"Language: en\n"
|
4
|
-
"X-Generator: Twine <%= Twine::VERSION %>\n"
|
5
|
-
|
6
|
-
|
7
|
-
# SECTION: My Strings
|
8
|
-
#. "This is a comment"
|
9
|
-
msgctxt "key1"
|
10
|
-
msgid "key1-english"
|
11
|
-
msgstr "key1-english"
|
12
|
-
|
13
|
-
msgctxt "key3"
|
14
|
-
msgid "key3-english"
|
15
|
-
msgstr "key3-english"
|
16
|
-
|
@@ -1,9 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
2
|
-
<!-- Android Strings File -->
|
3
|
-
<!-- Generated by Twine <%= Twine::VERSION %> -->
|
4
|
-
<!-- Language: en -->
|
5
|
-
<resources>
|
6
|
-
<!-- SECTION: My Strings -->
|
7
|
-
<string name="parameterized_string">The %1$s brown fox jumps over the %2$s dog %3$d times.</string>
|
8
|
-
<string name="percentage_string">This product is %d%% off.</string>
|
9
|
-
</resources>
|
@@ -1,21 +0,0 @@
|
|
1
|
-
[[Uncategorized]]
|
2
|
-
[key5]
|
3
|
-
en = A new string
|
4
|
-
|
5
|
-
[[My Strings]]
|
6
|
-
[key1]
|
7
|
-
en = key1-english
|
8
|
-
tags = tag1
|
9
|
-
comment = This is a comment
|
10
|
-
es = key1-spanish
|
11
|
-
fr = key1-french
|
12
|
-
[key2]
|
13
|
-
en = key2-english
|
14
|
-
tags = tag2
|
15
|
-
fr = key2-french
|
16
|
-
[key3]
|
17
|
-
en = key3-english
|
18
|
-
tags = tag1,tag2
|
19
|
-
es = key3-spanish
|
20
|
-
[key4]
|
21
|
-
en = A multiline string\ncan occur
|
data/test/twine_test.rb
DELETED
@@ -1,134 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'rubygems'
|
3
|
-
require 'test/unit'
|
4
|
-
require 'twine'
|
5
|
-
|
6
|
-
class TwineTest < Test::Unit::TestCase
|
7
|
-
def test_generate_string_file_1
|
8
|
-
Dir.mktmpdir do |dir|
|
9
|
-
output_path = File.join(dir, 'fr.xml')
|
10
|
-
Twine::Runner.run(%W(generate-string-file test/fixtures/strings-1.txt #{output_path} --include-untranslated))
|
11
|
-
assert_equal(ERB.new(File.read('test/fixtures/test-output-1.txt')).result, File.read(output_path))
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_generate_string_file_2
|
16
|
-
Dir.mktmpdir do |dir|
|
17
|
-
output_path = File.join(dir, 'en.strings')
|
18
|
-
Twine::Runner.run(%W(generate-string-file test/fixtures/strings-1.txt #{output_path} -t tag1))
|
19
|
-
assert_equal(ERB.new(File.read('test/fixtures/test-output-2.txt')).result, File.read(output_path))
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_generate_string_file_3
|
24
|
-
Dir.mktmpdir do |dir|
|
25
|
-
output_path = File.join(dir, 'en.json')
|
26
|
-
Twine::Runner.run(%W(generate-string-file test/fixtures/strings-1.txt #{output_path} -t tag1))
|
27
|
-
assert_equal(ERB.new(File.read('test/fixtures/test-output-5.txt')).result, File.read(output_path))
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_generate_string_file_4
|
32
|
-
Dir.mktmpdir do |dir|
|
33
|
-
output_path = File.join(dir, 'en.strings')
|
34
|
-
Twine::Runner.run(%W(generate-string-file test/fixtures/strings-2.txt #{output_path} -t tag1))
|
35
|
-
assert_equal(ERB.new(File.read('test/fixtures/test-output-6.txt')).result, File.read(output_path))
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_generate_string_file_5
|
40
|
-
Dir.mktmpdir do |dir|
|
41
|
-
output_path = File.join(dir, 'en.po')
|
42
|
-
Twine::Runner.run(%W(generate-string-file test/fixtures/strings-1.txt #{output_path} -t tag1))
|
43
|
-
assert_equal(ERB.new(File.read('test/fixtures/test-output-7.txt')).result, File.read(output_path))
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_generate_string_file_6
|
48
|
-
Dir.mktmpdir do |dir|
|
49
|
-
output_path = File.join(dir, 'en.xml')
|
50
|
-
Twine::Runner.run(%W(generate-string-file test/fixtures/strings-3.txt #{output_path}))
|
51
|
-
assert_equal(ERB.new(File.read('test/fixtures/test-output-8.txt')).result, File.read(output_path))
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_generate_string_file_7
|
56
|
-
Dir.mktmpdir do |dir|
|
57
|
-
output_path = File.join(dir, 'en.xml')
|
58
|
-
Twine::Runner.run(%W(generate-string-file test/fixtures/strings-2.txt #{output_path} -t tag1))
|
59
|
-
assert_equal(ERB.new(File.read('test/fixtures/test-output-10.txt')).result, File.read(output_path))
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_generate_string_file_8
|
64
|
-
Dir.mktmpdir do |dir|
|
65
|
-
output_path = File.join(dir, 'fr.xml')
|
66
|
-
Twine::Runner.run(%W(generate-string-file --format tizen test/fixtures/strings-1.txt #{output_path} --include-untranslated))
|
67
|
-
assert_equal(ERB.new(File.read('test/fixtures/test-output-12.txt')).result, File.read(output_path))
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_consume_string_file_1
|
72
|
-
Dir.mktmpdir do |dir|
|
73
|
-
output_path = File.join(dir, 'strings.txt')
|
74
|
-
Twine::Runner.run(%W(consume-string-file test/fixtures/strings-1.txt test/fixtures/fr-1.xml -o #{output_path} -l fr))
|
75
|
-
assert_equal(File.read('test/fixtures/test-output-3.txt'), File.read(output_path))
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def test_consume_string_file_2
|
80
|
-
Dir.mktmpdir do |dir|
|
81
|
-
output_path = File.join(dir, 'strings.txt')
|
82
|
-
Twine::Runner.run(%W(consume-string-file test/fixtures/strings-1.txt test/fixtures/en-1.strings -o #{output_path} -l en -a))
|
83
|
-
assert_equal(File.read('test/fixtures/test-output-4.txt'), File.read(output_path))
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_consume_string_file_3
|
88
|
-
Dir.mktmpdir do |dir|
|
89
|
-
output_path = File.join(dir, 'strings.txt')
|
90
|
-
Twine::Runner.run(%W(consume-string-file test/fixtures/strings-1.txt test/fixtures/en-1.json -o #{output_path} -l en -a))
|
91
|
-
assert_equal(File.read('test/fixtures/test-output-4.txt'), File.read(output_path))
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def test_consume_string_file_4
|
96
|
-
Dir.mktmpdir do |dir|
|
97
|
-
output_path = File.join(dir, 'strings.txt')
|
98
|
-
Twine::Runner.run(%W(consume-string-file test/fixtures/strings-1.txt test/fixtures/en-1.po -o #{output_path} -l en -a))
|
99
|
-
assert_equal(File.read('test/fixtures/test-output-4.txt'), File.read(output_path))
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_consume_string_file_5
|
104
|
-
Dir.mktmpdir do |dir|
|
105
|
-
output_path = File.join(dir, 'strings.txt')
|
106
|
-
Twine::Runner.run(%W(consume-string-file test/fixtures/strings-1.txt test/fixtures/en-2.po -o #{output_path} -l en -a))
|
107
|
-
assert_equal(File.read('test/fixtures/test-output-9.txt'), File.read(output_path))
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def test_consume_string_file_6
|
112
|
-
Dir.mktmpdir do |dir|
|
113
|
-
output_path = File.join(dir, 'strings.txt')
|
114
|
-
Twine::Runner.run(%W(consume-string-file test/fixtures/strings-2.txt test/fixtures/en-3.xml -o #{output_path} -l en -a))
|
115
|
-
assert_equal(File.read('test/fixtures/test-output-11.txt'), File.read(output_path))
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_json_line_breaks_consume
|
120
|
-
Dir.mktmpdir do |dir|
|
121
|
-
output_path = File.join(dir, 'strings.txt')
|
122
|
-
Twine::Runner.run(%W(consume-string-file test/fixtures/test-json-line-breaks/line-breaks.txt test/fixtures/test-json-line-breaks/line-breaks.json -l fr -o #{output_path}))
|
123
|
-
assert_equal(File.read('test/fixtures/test-json-line-breaks/consumed.txt'), File.read(output_path))
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def test_json_line_breaks_generate
|
128
|
-
Dir.mktmpdir do |dir|
|
129
|
-
output_path = File.join(dir, 'en.json')
|
130
|
-
Twine::Runner.run(%W(generate-string-file test/fixtures/test-json-line-breaks/line-breaks.txt #{output_path}))
|
131
|
-
assert_equal(File.read('test/fixtures/test-json-line-breaks/generated.json'), File.read(output_path))
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|