twine 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +34 -16
- data/lib/twine/formatters/android.rb +11 -9
- data/lib/twine/formatters/apple.rb +11 -3
- data/lib/twine/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -8,16 +8,16 @@ Twine is a command line tool for managing your strings and their translations. T
|
|
8
8
|
|
9
9
|
Twine is most easily installed as a Gem.
|
10
10
|
|
11
|
-
|
11
|
+
$ gem install twine
|
12
12
|
|
13
13
|
### From Source
|
14
14
|
|
15
15
|
You can also run Twine directly from source. However, it requires [rubyzip][rubyzip] in order to create and read standard zip files.
|
16
16
|
|
17
|
-
|
18
|
-
git clone git://github.com/mobiata/twine.git
|
19
|
-
cd twine
|
20
|
-
./twine --help
|
17
|
+
$ gem install rubyzip
|
18
|
+
$ git clone git://github.com/mobiata/twine.git
|
19
|
+
$ cd twine
|
20
|
+
$ ./twine --help
|
21
21
|
|
22
22
|
Make sure you run the `twine` executable at the root of the project as it properly sets up your Ruby library path. The `bin/twine` executable does not.
|
23
23
|
|
@@ -78,42 +78,60 @@ Whitepace in this file is mostly ignored. If you absolutely need to put spaces a
|
|
78
78
|
|
79
79
|
This command creates an Apple or Android strings file from the master strings data file.
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
81
|
+
$ twine generate-string-file /path/to/strings.txt values-ja.xml --tag common,app1
|
82
|
+
$ twine generate-string-file /path/to/strings.txt Localizable.strings --lang ja --tag mytag
|
83
|
+
$ twine generate-string-file /path/to/strings.txt all-english.strings --lang en
|
84
84
|
|
85
85
|
#### `generate-all-string-files`
|
86
86
|
|
87
87
|
This command is a convenient way to call `generate-string-file` multiple times. It uses standard Mac OS X, iOS, and Android conventions to figure out exactly which files to create given a parent directory. For example, if you point it to a parent directory containing `en.lproj`, `fr.lproj`, and `ja.lproj` subdirectories, Twine will create a `Localizable.strings` file of the appropriate language in each of them. This is often the command you will want to execute during the build phase of your project.
|
88
88
|
|
89
|
-
|
89
|
+
$ twine generate-all-string-files /path/to/strings.txt /path/to/project/locales/directory --tag common,app1
|
90
90
|
|
91
91
|
#### `consume-string-file`
|
92
92
|
|
93
93
|
This command slurps all of the strings from a `.strings` or `.xml` file and incorporates the translated text into the master strings data file. This is a simple way to incorporate any changes made to a single file by one of your translators. It will only identify strings that already exist in the master data file.
|
94
94
|
|
95
|
-
|
96
|
-
|
97
|
-
|
95
|
+
$ twine consume-string-file /path/to/strings.txt fr.strings
|
96
|
+
$ twine consume-string-file /path/to/strings.txt Localizable.strings --lang ja
|
97
|
+
$ twine consume-string-file /path/to/strings.txt es.xml
|
98
98
|
|
99
99
|
#### `generate-loc-drop`
|
100
100
|
|
101
101
|
This command is a convenient way to generate a zip file containing files created by the `generate-string-file` command. It is often used for creating a single zip containing a large number of strings in all languages which you can then hand off to your translation team.
|
102
102
|
|
103
|
-
|
104
|
-
|
103
|
+
$ twine generate-loc-drop /path/to/strings.txt LocDrop1.zip
|
104
|
+
$ twine generate-loc-drop /path/to/strings.txt LocDrop2.zip --lang en,fr,ja,ko --tag common,app1
|
105
105
|
|
106
106
|
#### `consume-loc-drop`
|
107
107
|
|
108
108
|
This command is a convenient way of taking a zip file and executing the `consume-string-file` command on each file within the archive. It is most often used to incorporate all of the changes made by the translation team after they have completed work on a localization drop.
|
109
109
|
|
110
|
-
|
110
|
+
$ twine consume-loc-drop /path/to/strings.txt LocDrop2.zip
|
111
111
|
|
112
112
|
#### `generate-report`
|
113
113
|
|
114
114
|
This command gives you useful information about your strings. It will tell you how many strings you have, how many have been translated into each language, and whether your master strings data file has any duplicate string keys.
|
115
115
|
|
116
|
-
|
116
|
+
$ twine generate-report /path/to/strings.txt
|
117
|
+
|
118
|
+
## Twine in your Build Process
|
119
|
+
|
120
|
+
It is easy to incorporate Twine right into your iOS and Mac OS X app build processes.
|
121
|
+
|
122
|
+
1. In your project folder, create all of the `.lproj` directories that you need. It does not really matter where they are. We tend to put them in `Resources/Locales/`.
|
123
|
+
2. Run the `generate-all-string-files` command to create all of the string files you need in these directories. For example,
|
124
|
+
|
125
|
+
$ twine generate-all-string-files strings.txt Resources/Locales/ --tags tag1,tag2
|
126
|
+
|
127
|
+
Make sure you point Twine at your strings data file, the directory that contains all of your `.lproj` directories, and and the tags that describe the strings you want to use for this project.
|
128
|
+
3. Drag the `Resources/Locales/` directory to the Xcode project navigator so that Xcode knows to include all of these strings files in your build.
|
129
|
+
4. In Xcode, navigate to the "Build Phases" tab of your target.
|
130
|
+
5. Click on the "Add Build Phase" button and select "Add Run Script".
|
131
|
+
6. Drag the new "Run Script" build phase up so that it runs earlier in the build process. It doesn't really matter where, as long as it happens before the resources are copied to your bundle.
|
132
|
+
7. Edit your script to run the exact same command you ran in step (2) above.
|
133
|
+
|
134
|
+
Now, whenever you build your application, Xcode will automatically invoke Twine to make sure that your `.strings` files are always up-to-date.
|
117
135
|
|
118
136
|
[rubyzip]: http://rubygems.org/gems/rubyzip
|
119
137
|
[git]: http://git-scm.org/
|
@@ -53,18 +53,20 @@ module Twine
|
|
53
53
|
default_lang = strings.language_codes[0]
|
54
54
|
File.open(path, 'w:UTF-8') do |f|
|
55
55
|
f.puts "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Android Strings File -->\n<!-- Generated by Twine -->\n<!-- Language: #{lang} -->"
|
56
|
-
f.
|
57
|
-
section_num = -1
|
56
|
+
f.write '<resources>'
|
58
57
|
strings.sections.each do |section|
|
59
|
-
|
60
|
-
if section_num > 0
|
61
|
-
f.puts ''
|
62
|
-
end
|
63
|
-
|
64
|
-
section_name = section.name.gsub('--', '—')
|
65
|
-
f.puts "\t<!-- #{section_name} -->"
|
58
|
+
printed_section = false
|
66
59
|
section.rows.each do |row|
|
67
60
|
if row_matches_tags?(row, tags)
|
61
|
+
unless printed_section
|
62
|
+
f.puts ''
|
63
|
+
if section.name && section.name.length > 0
|
64
|
+
section_name = section.name.gsub('--', '—')
|
65
|
+
f.puts "\t<!-- #{section_name} -->"
|
66
|
+
end
|
67
|
+
printed_section = true
|
68
|
+
end
|
69
|
+
|
68
70
|
key = row.key
|
69
71
|
key = CGI.escapeHTML(key)
|
70
72
|
|
@@ -26,7 +26,7 @@ module Twine
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def read_file(path, lang, strings)
|
29
|
-
File.open(path, 'r:UTF-
|
29
|
+
File.open(path, 'r:UTF-8') do |f|
|
30
30
|
while line = f.gets
|
31
31
|
match = /"((?:[^"\\]|\\.)+)"\s*=\s*"((?:[^"\\]|\\.)*)/.match(line)
|
32
32
|
if match
|
@@ -46,12 +46,20 @@ module Twine
|
|
46
46
|
|
47
47
|
def write_file(path, lang, tags, strings)
|
48
48
|
default_lang = strings.language_codes[0]
|
49
|
-
File.open(path, 'w:UTF-
|
49
|
+
File.open(path, 'w:UTF-8') do |f|
|
50
50
|
f.puts "/**\n * iOS Strings File\n * Generated by Twine\n * Language: #{lang}\n */"
|
51
51
|
strings.sections.each do |section|
|
52
|
-
|
52
|
+
printed_section = false
|
53
53
|
section.rows.each do |row|
|
54
54
|
if row_matches_tags?(row, tags)
|
55
|
+
unless printed_section
|
56
|
+
f.puts ''
|
57
|
+
if section.name && section.name.length > 0
|
58
|
+
f.puts "/* #{section.name} */"
|
59
|
+
end
|
60
|
+
printed_section = true
|
61
|
+
end
|
62
|
+
|
55
63
|
key = row.key
|
56
64
|
key = key.gsub('"', '\\\\"')
|
57
65
|
|
data/lib/twine/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubyzip
|
16
|
-
requirement: &
|
16
|
+
requirement: &70309529145320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 0.9.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70309529145320
|
25
25
|
description: ! " Twine is a command line tool for managing your strings and their
|
26
26
|
translations.\n \n It is geared toward Mac OS X, iOS, and Android developers.\n"
|
27
27
|
email: twine@mobiata.com
|