twine 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c52c16544077b748fb773dd7cd3f8d7f88172eeb
4
- data.tar.gz: a4db219ebbef41d69c00a59e46d09971be26ba4a
3
+ metadata.gz: dd42325c94b784158be7dd018af67a02fb3099b0
4
+ data.tar.gz: 7ee4dae663a07911d402a236fb1f40692b58cc43
5
5
  SHA512:
6
- metadata.gz: 18423f5df5e0feda3ebd2e5e74c65ccb1bea506022ec79ee0d180f609e7acb2402348e1c37f78e02e00eee02933e6f6ba0f308b23e846d7e5e4e8896ad49b9c3
7
- data.tar.gz: 010dca262cae3a0766d99d5a34aede2c05dba4ad5489d03c4798808cea3902fe3c5c443302e38712af26be12c3f8dedc442f3a25da2d483fc00adce9f5c36b4a
6
+ metadata.gz: 54345a2371c8717af7b2285b7fee737b082695501da2e5ecaaee04f76762b6aa2a31eefc0c42c5a95d15ae06af38d1e8b31dfb34b6a20b56c86417044667255e
7
+ data.tar.gz: 681b338e4b3f9efc9af0659c785b8fcaabb3878e6b3080b8fce7aca0856094e52f0414f25591c27c7d2688c82c45e671ddd6bbb2d25c59afdadb16858005d427
data/README.md CHANGED
@@ -29,7 +29,7 @@ Each grouping section contains N string definitions. These string definitions st
29
29
 
30
30
  ### Tags
31
31
 
32
- Tags are used by Twine as a way to only work with a subset of your strings at any given point in time. Each string can be assigned zero or more tags which are separated by commas. Tags are optional, though highly recommended. You can get a list of all strings currently missing tags by executing the `generate-report` command.
32
+ Tags are used by Twine as a way to only work with a subset of your strings at any given point in time. Each string can be assigned zero or more tags which are separated by commas. Tags are optional, though highly recommended. You can get a list of all strings currently missing tags by executing the `validate-strings-file` command.
33
33
 
34
34
  ### Whitespace
35
35
 
@@ -47,7 +47,7 @@ Whitepace in this file is mostly ignored. If you absolutely need to put spaces a
47
47
  en = No
48
48
  fr = Non
49
49
  ja = いいえ
50
-
50
+
51
51
  [[Errors]]
52
52
  [path_not_found_error]
53
53
  en = The file '%@' could not be found.
@@ -57,7 +57,7 @@ Whitepace in this file is mostly ignored. If you absolutely need to put spaces a
57
57
  en = The network is currently unavailable.
58
58
  tags = app1
59
59
  comment = An error describing when the device can not connect to the internet.
60
-
60
+
61
61
  [[Escaping Example]]
62
62
  [list_item_separator]
63
63
  en = `, `
@@ -84,7 +84,7 @@ If you would like to enable twine to create language files in another format, cr
84
84
  ## Usage
85
85
 
86
86
  Usage: twine COMMAND STRINGS_FILE [INPUT_OR_OUTPUT_PATH] [--lang LANG1,LANG2...] [--tags TAG1,TAG2,TAG3...] [--format FORMAT]
87
-
87
+
88
88
  ### Commands
89
89
 
90
90
  #### `generate-string-file`
@@ -128,11 +128,11 @@ This command is a convenient way of taking a zip file and executing the `consume
128
128
 
129
129
  $ twine consume-loc-drop /path/to/strings.txt LocDrop2.zip
130
130
 
131
- #### `generate-report`
131
+ #### `validate-strings-file`
132
132
 
133
- 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.
133
+ This command validates that the strings file can be parsed, contains no duplicate keys, and that all strings have at least one tag. It will exit with a non-zero status code if any of those criteria are not met.
134
134
 
135
- $ twine generate-report /path/to/strings.txt
135
+ $ twine validate-strings-file /path/to/strings.txt
136
136
 
137
137
  ## Creating Your First strings.txt File
138
138
 
@@ -143,6 +143,8 @@ The easiest way to create your first strings.txt file is to run the `consume-all
143
143
 
144
144
  ## Twine and Your Build Process
145
145
 
146
+ ### Xcode
147
+
146
148
  It is easy to incorporate Twine right into your iOS and OS X app build processes.
147
149
 
148
150
  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/`.
@@ -159,6 +161,22 @@ It is easy to incorporate Twine right into your iOS and OS X app build processes
159
161
 
160
162
  Now, whenever you build your application, Xcode will automatically invoke Twine to make sure that your `.strings` files are up-to-date.
161
163
 
164
+ ### Android Studio/Gradle
165
+
166
+ Add the following task at the top level in app/build.gradle:
167
+ ```
168
+ task generateStrings {
169
+ String script = 'if hash twine 2>/dev/null; then twine generate-string-file strings.txt ./src/main/res/values/generated_strings.xml; fi'
170
+ exec {
171
+ executable "sh"
172
+ args '-c', script
173
+ }
174
+ }
175
+ ```
176
+
177
+ Now every time you build your app the strings are generated from the twine file.
178
+
179
+
162
180
  ## User Interface
163
181
 
164
182
  * [Twine TextMate 2 Bundle](https://github.com/mobiata/twine.tmbundle) — This [TextMate 2](https://github.com/textmate/textmate) bundle will make it easier for you to work with Twine strings files. In particular, it lets you use code folding to easily collapse and expand both strings and sections.
@@ -191,6 +209,7 @@ gems: [appium_twine, some_other_plugin]
191
209
  Many thanks to all of the contributors to the Twine project, including:
192
210
 
193
211
  * [Blake Watters](https://github.com/blakewatters)
212
+ * [bootstraponline](https://github.com/bootstraponline)
194
213
  * [Ishitoya Kentaro](https://github.com/kent013)
195
214
  * [Joseph Earl](https://github.com/JosephEarl)
196
215
  * [Kevin Everets](https://github.com/keverets)
@@ -15,7 +15,7 @@ module Twine
15
15
  parser = OptionParser.new do |opts|
16
16
  opts.banner = 'Usage: twine COMMAND STRINGS_FILE [INPUT_OR_OUTPUT_PATH] [--lang LANG1,LANG2...] [--tags TAG1,TAG2,TAG3...] [--format FORMAT]'
17
17
  opts.separator ''
18
- opts.separator 'The purpose of this script is to convert back and forth between multiple data formats, allowing us to treat our strings (and translations) as data stored in a text file. We can then use the data file to create drops for the localization team, consume similar drops returned by the localization team, generate reports on the strings, as well as create formatted string files to ship with your products. Twine currently supports iOS, OS X, Android, gettext, and jquery-localize string files.'
18
+ opts.separator 'The purpose of this script is to convert back and forth between multiple data formats, allowing us to treat our strings (and translations) as data stored in a text file. We can then use the data file to create drops for the localization team, consume similar drops returned by the localization team, and create formatted string files to ship with your products. Twine currently supports iOS, OS X, Android, gettext, and jquery-localize string files.'
19
19
  opts.separator ''
20
20
  opts.separator 'Commands:'
21
21
  opts.separator ''
@@ -31,7 +31,7 @@ module Twine
31
31
  opts.separator ''
32
32
  opts.separator 'consume-loc-drop -- Consumes an archive of translated files. This archive should be in the same format as the one created by the generate-loc-drop command.'
33
33
  opts.separator ''
34
- opts.separator 'generate-report -- Generates a report containing data about your strings. For example, it will tell you if you have any duplicate strings or if any of your strings are missing tags. In addition, it will tell you how many strings you have and how many of those strings have been translated into each language.'
34
+ opts.separator 'validate-strings-file -- Validates that the given strings file is parseable, contains no duplicates, and that every string has a tag. Exits with a non-zero exit code if those criteria are not met.'
35
35
  opts.separator ''
36
36
  opts.separator 'General Options:'
37
37
  opts.separator ''
@@ -96,7 +96,7 @@ module Twine
96
96
  opts.separator '> twine consume-all-string-files strings.txt Resources/Locales/ --developer-language en --tags DefaultTag1,DefaultTag2'
97
97
  opts.separator '> twine generate-loc-drop strings.txt LocDrop5.zip --tags FT,FB --format android --lang de,en,en-GB,ja,ko'
98
98
  opts.separator '> twine consume-loc-drop strings.txt LocDrop5.zip'
99
- opts.separator '> twine generate-report strings.txt'
99
+ opts.separator '> twine validate-strings-file strings.txt'
100
100
  end
101
101
  parser.parse! @args
102
102
 
@@ -176,7 +176,7 @@ module Twine
176
176
  else
177
177
  raise Twine::Error.new 'Not enough arguments.'
178
178
  end
179
- when 'generate-report'
179
+ when 'validate-strings-file'
180
180
  if @args.length > 2
181
181
  raise Twine::Error.new "Unknown argument: #{@args[2]}"
182
182
  end
@@ -18,7 +18,9 @@ module Twine
18
18
  path_arr.each do |segment|
19
19
  match = /^(.+)\.lproj$/.match(segment)
20
20
  if match
21
- return match[1]
21
+ if match[1] != "Base"
22
+ return match[1]
23
+ end
22
24
  end
23
25
  end
24
26
 
@@ -3,7 +3,7 @@ require 'tmpdir'
3
3
  Twine::Plugin.new # Initialize plugins first in Runner.
4
4
 
5
5
  module Twine
6
- VALID_COMMANDS = ['generate-string-file', 'generate-all-string-files', 'consume-string-file', 'consume-all-string-files', 'generate-loc-drop', 'consume-loc-drop', 'generate-report']
6
+ VALID_COMMANDS = ['generate-string-file', 'generate-all-string-files', 'consume-string-file', 'consume-all-string-files', 'generate-loc-drop', 'consume-loc-drop', 'validate-strings-file']
7
7
 
8
8
  class Runner
9
9
  def initialize(args)
@@ -48,8 +48,8 @@ module Twine
48
48
  generate_loc_drop
49
49
  when 'consume-loc-drop'
50
50
  consume_loc_drop
51
- when 'generate-report'
52
- generate_report
51
+ when 'validate-strings-file'
52
+ validate_strings_file
53
53
  end
54
54
  end
55
55
 
@@ -207,15 +207,12 @@ module Twine
207
207
  write_strings_data(output_path)
208
208
  end
209
209
 
210
- def generate_report
210
+ def validate_strings_file
211
211
  total_strings = 0
212
- strings_per_lang = {}
213
212
  all_keys = Set.new
214
213
  duplicate_keys = Set.new
215
214
  keys_without_tags = Set.new
216
- @strings.language_codes.each do |code|
217
- strings_per_lang[code] = 0
218
- end
215
+ errors = []
219
216
 
220
217
  @strings.sections.each do |section|
221
218
  section.rows.each do |row|
@@ -227,37 +224,29 @@ module Twine
227
224
  all_keys.add(row.key)
228
225
  end
229
226
 
230
- row.translations.each_key do |code|
231
- strings_per_lang[code] += 1
232
- end
233
-
234
227
  if row.tags == nil || row.tags.length == 0
235
228
  keys_without_tags.add(row.key)
236
229
  end
237
230
  end
238
231
  end
239
232
 
240
- # Print the report.
241
- puts "Total number of strings = #{total_strings}"
242
- @strings.language_codes.each do |code|
243
- puts "#{code}: #{strings_per_lang[code]}"
244
- end
245
-
246
233
  if duplicate_keys.length > 0
247
- puts "\nDuplicate string keys:"
248
- duplicate_keys.each do |key|
249
- puts key
250
- end
234
+ error_body = duplicate_keys.to_a.join("\n ")
235
+ errors << "Found duplicate string key(s):\n #{error_body}"
251
236
  end
252
237
 
253
238
  if keys_without_tags.length == total_strings
254
- puts "\nNone of your strings have tags."
239
+ errors << "None of your strings have tags."
255
240
  elsif keys_without_tags.length > 0
256
- puts "\nStrings without tags:"
257
- keys_without_tags.each do |key|
258
- puts key
259
- end
241
+ error_body = keys_without_tags.to_a.join("\n ")
242
+ errors << "Found strings(s) without tags:\n #{error_body}"
260
243
  end
244
+
245
+ if errors.length > 0
246
+ raise Twine::Error.new errors.join("\n\n")
247
+ end
248
+
249
+ puts "#{@options[:strings_file]} is valid."
261
250
  end
262
251
 
263
252
  def determine_language_given_path(path)
@@ -1,3 +1,3 @@
1
1
  module Twine
2
- VERSION = '0.6.0'
2
+ VERSION = '0.7.0'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <!-- Android Strings File -->
3
- <!-- Generated by Twine 0.5.0 -->
3
+ <!-- Generated by Twine <%= Twine::VERSION %> -->
4
4
  <!-- Language: en -->
5
5
  <resources>
6
6
  <!-- SECTION: My Strings -->
@@ -116,10 +116,6 @@ class TwineTest < Test::Unit::TestCase
116
116
  end
117
117
  end
118
118
 
119
- def test_generate_report_1
120
- Twine::Runner.run(%w(generate-report test/fixtures/strings-1.txt))
121
- end
122
-
123
119
  def test_json_line_breaks_consume
124
120
  Dir.mktmpdir do |dir|
125
121
  output_path = File.join(dir, 'strings.txt')
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Celis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-20 00:00:00.000000000 Z
11
+ date: 2015-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.9.5
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.9.5
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: safe_yaml
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.0.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.0.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.9.2
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.9.2
55
55
  description: |2
@@ -63,10 +63,13 @@ extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
65
  - Gemfile
66
- - README.md
67
66
  - LICENSE
67
+ - README.md
68
+ - bin/twine
69
+ - lib/twine.rb
68
70
  - lib/twine/cli.rb
69
71
  - lib/twine/encoding.rb
72
+ - lib/twine/formatters.rb
70
73
  - lib/twine/formatters/abstract.rb
71
74
  - lib/twine/formatters/android.rb
72
75
  - lib/twine/formatters/apple.rb
@@ -75,13 +78,10 @@ files:
75
78
  - lib/twine/formatters/gettext.rb
76
79
  - lib/twine/formatters/jquery.rb
77
80
  - lib/twine/formatters/tizen.rb
78
- - lib/twine/formatters.rb
79
81
  - lib/twine/plugin.rb
80
82
  - lib/twine/runner.rb
81
83
  - lib/twine/stringsfile.rb
82
84
  - lib/twine/version.rb
83
- - lib/twine.rb
84
- - bin/twine
85
85
  - test/fixtures/en-1.json
86
86
  - test/fixtures/en-1.po
87
87
  - test/fixtures/en-1.strings
@@ -117,17 +117,17 @@ require_paths:
117
117
  - lib
118
118
  required_ruby_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - '>='
120
+ - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: 1.8.7
123
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  requirements:
125
- - - '>='
125
+ - - ">="
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  requirements: []
129
129
  rubyforge_project:
130
- rubygems_version: 2.0.14
130
+ rubygems_version: 2.2.2
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: Manage strings and their translations for your iOS and Android projects.