twine 1.1.1 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -6
- data/lib/twine/formatters/jquery.rb +11 -1
- data/lib/twine/output_processor.rb +1 -0
- data/lib/twine/twine_file.rb +1 -1
- data/lib/twine/version.rb +1 -1
- data/test/fixtures/formatter_jquery_nested.json +11 -0
- data/test/test_formatters.rb +14 -0
- metadata +29 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0ddd09377d4bdc637c451ef936e94532bd6af7986cbe7ff490732ff0a42ff6d
|
4
|
+
data.tar.gz: 93dbc48a7c9b10681ddbc0fc996f02e15c8658144da6d1a285628543cec30a5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5565a7205236780b07f99b1fc8e7d7e8a22b11ee67bf08137aed0660cf49e283bbdfc9d86e2073dc689b98a5167de9bd2f17c5cde266580455e04d66d92559ac
|
7
|
+
data.tar.gz: 47616ba00b6f17de2eda9aac730b4595e21a2e43395b1bc95a6eb5bd44d656d31c71f9fbab87d8ff7d393357602998769f511930dee1c23ca6372e956d425000
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# Twine
|
2
2
|
|
3
|
-
[![Continuous Integration by CircleCI](https://circleci.com/gh/scelis/twine.svg?style=shield)](https://circleci.com/gh/scelis/twine)
|
4
|
-
|
5
3
|
Twine is a command line tool for managing your strings and their translations. These are all stored in a single text file and then Twine uses this file to import and export localization files in a variety of types, including iOS and Mac OS X `.strings` files, Android `.xml` files, gettext `.po` files, and [jquery-localize][jquerylocalize] `.json` files. This allows individuals and companies to easily share translations across multiple projects, as well as export localization files in any format the user wants.
|
6
4
|
|
7
5
|
## Install
|
@@ -24,7 +22,7 @@ Twine supports [`printf` style placeholders][printf] with one peculiarity: `@` i
|
|
24
22
|
|
25
23
|
Tags are used by Twine as a way to only work with a subset of your definitions at any given point in time. Each definition 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 definitions currently missing tags by executing the [`validate-twine-file`](#validate-twine-file) command with the `--pedantic` option.
|
26
24
|
|
27
|
-
When generating a localization file, you can specify which definitions should be included using the `--tags` option. Provide a comma separated list of tags to match all definitions that contain any of the tags (`--tags tag1,tag2` matches all definitions tagged with `tag1` _or_ `tag2`). Provide multiple `--tags` options to match
|
25
|
+
When generating a localization file, you can specify which definitions should be included using the `--tags` option. Provide a comma separated list of tags to match all definitions that contain any of the tags (`--tags tag1,tag2` matches all definitions tagged with `tag1` _or_ `tag2`). Provide multiple `--tags` options to match definitions containing all specified tags (`--tags tag1 --tags tag2` matches all definitions tagged with `tag1` _and_ `tag2`). You can match definitions _not_ containing a tag by prefixing the tag with a tilde (`--tags ~tag1` matches all definitions _not_ tagged with `tag1`). All three options are combinable.
|
28
26
|
|
29
27
|
### Whitespace
|
30
28
|
|
@@ -81,7 +79,7 @@ Twine currently supports the following output formats:
|
|
81
79
|
* HTML tags will be escaped by replacing `<` with `<`
|
82
80
|
* Tags inside `<![CDATA[` won't be escaped.
|
83
81
|
* Supports [basic styling][androidstyling] according to [Android documentation](https://developer.android.com/guide/topics/resources/string-resource.html#StylingWithHTML). All of the documented tags are supported, in addition to `<a>` links.
|
84
|
-
* These tags will *not* be escaped if the string doesn't contain placeholders. You can reference them directly in your layouts or by using [`getText()`](https://developer.android.com/reference/android/content/res/Resources.html#getText(int)) to read them
|
82
|
+
* These tags will *not* be escaped if the string doesn't contain placeholders. You can reference them directly in your layouts or by using [`getText()`](https://developer.android.com/reference/android/content/res/Resources.html#getText(int)) to read them programmatically.
|
85
83
|
* These tags *will* be escaped if the string contains placeholders. You can use [`getString()`](https://developer.android.com/reference/android/content/res/Resources.html#getString(int,%20java.lang.Object...)) combined with [`fromHtml`](https://developer.android.com/reference/android/text/Html.html#fromHtml(java.lang.String)) as shown in the [documentation][androidstyling] to display them.
|
86
84
|
* See [\#212](https://github.com/scelis/twine/issues/212) for details.
|
87
85
|
* [Gettext PO Files][gettextpo] (format: gettext)
|
@@ -203,7 +201,7 @@ buildscript {
|
|
203
201
|
repositories { jcenter() }
|
204
202
|
|
205
203
|
dependencies {
|
206
|
-
/* NOTE: Set your
|
204
|
+
/* NOTE: Set your preferred version of jruby here. */
|
207
205
|
classpath "com.github.jruby-gradle:jruby-gradle-plugin:1.5.0"
|
208
206
|
}
|
209
207
|
}
|
@@ -211,7 +209,7 @@ buildscript {
|
|
211
209
|
apply plugin: 'com.github.jruby-gradle.base'
|
212
210
|
|
213
211
|
dependencies {
|
214
|
-
/* NOTE: Set your
|
212
|
+
/* NOTE: Set your preferred version of twine here. */
|
215
213
|
jrubyExec 'rubygems:twine:1.1'
|
216
214
|
}
|
217
215
|
|
@@ -20,6 +20,16 @@ module Twine
|
|
20
20
|
return super
|
21
21
|
end
|
22
22
|
|
23
|
+
def set_translation_for_key_recursive(key, lang, value)
|
24
|
+
if value.is_a?(Hash)
|
25
|
+
value.each do |key2, value2|
|
26
|
+
set_translation_for_key_recursive(key+"."+key2, lang, value2)
|
27
|
+
end
|
28
|
+
else
|
29
|
+
set_translation_for_key(key, lang, value)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
23
33
|
def read(io, lang)
|
24
34
|
begin
|
25
35
|
require "json"
|
@@ -29,7 +39,7 @@ module Twine
|
|
29
39
|
|
30
40
|
json = JSON.load(io)
|
31
41
|
json.each do |key, value|
|
32
|
-
|
42
|
+
set_translation_for_key_recursive(key, lang, value)
|
33
43
|
end
|
34
44
|
end
|
35
45
|
|
data/lib/twine/twine_file.rb
CHANGED
@@ -44,7 +44,7 @@ module Twine
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def translation_for_lang(lang)
|
47
|
-
translation = [lang].flatten.map { |l| @translations[l] }.first
|
47
|
+
translation = [lang].flatten.map { |l| @translations[l] }.compact.first
|
48
48
|
|
49
49
|
translation = reference.translation_for_lang(lang) if translation.nil? && reference
|
50
50
|
|
data/lib/twine/version.rb
CHANGED
data/test/test_formatters.rb
CHANGED
@@ -28,6 +28,14 @@ class FormatterTest < TwineTest
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
def assert_nested_translations_read_correctly
|
32
|
+
1.upto(4) do |i|
|
33
|
+
assert_equal "value#{i}-english", @empty_twine_file.definitions_by_key["key#{i}"].translations['en']
|
34
|
+
end
|
35
|
+
assert_equal "value5a-english", @empty_twine_file.definitions_by_key["key5.key5a"].translations['en']
|
36
|
+
assert_equal "value5b-english", @empty_twine_file.definitions_by_key["key5.key5b"].translations['en']
|
37
|
+
end
|
38
|
+
|
31
39
|
def assert_file_contents_read_correctly
|
32
40
|
assert_translations_read_correctly
|
33
41
|
|
@@ -442,6 +450,12 @@ class TestJQueryFormatter < FormatterTest
|
|
442
450
|
assert_translations_read_correctly
|
443
451
|
end
|
444
452
|
|
453
|
+
def test_read_format_nested
|
454
|
+
@formatter.read content_io('formatter_jquery_nested.json'), 'en'
|
455
|
+
|
456
|
+
assert_nested_translations_read_correctly
|
457
|
+
end
|
458
|
+
|
445
459
|
def test_format_file
|
446
460
|
formatter = Twine::Formatters::JQuery.new
|
447
461
|
formatter.twine_file = @twine_file
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Celis
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rexml
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rubyzip
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,6 +154,7 @@ files:
|
|
140
154
|
- test/fixtures/formatter_gettext.po
|
141
155
|
- test/fixtures/formatter_gettext_quotes.po
|
142
156
|
- test/fixtures/formatter_jquery.json
|
157
|
+
- test/fixtures/formatter_jquery_nested.json
|
143
158
|
- test/fixtures/formatter_tizen.xml
|
144
159
|
- test/fixtures/gettext_multiline.po
|
145
160
|
- test/fixtures/twine_accent_values.txt
|
@@ -162,7 +177,7 @@ homepage: https://github.com/scelis/twine
|
|
162
177
|
licenses:
|
163
178
|
- BSD-3-Clause
|
164
179
|
metadata: {}
|
165
|
-
post_install_message:
|
180
|
+
post_install_message:
|
166
181
|
rdoc_options: []
|
167
182
|
require_paths:
|
168
183
|
- lib
|
@@ -170,28 +185,28 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
185
|
requirements:
|
171
186
|
- - ">="
|
172
187
|
- !ruby/object:Gem::Version
|
173
|
-
version: '2.
|
188
|
+
version: '2.6'
|
174
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
190
|
requirements:
|
176
191
|
- - ">="
|
177
192
|
- !ruby/object:Gem::Version
|
178
193
|
version: '0'
|
179
194
|
requirements: []
|
180
|
-
rubygems_version: 3.
|
181
|
-
signing_key:
|
195
|
+
rubygems_version: 3.4.10
|
196
|
+
signing_key:
|
182
197
|
specification_version: 4
|
183
198
|
summary: Manage strings and their translations for your iOS, Android and other projects.
|
184
199
|
test_files:
|
185
|
-
- test/test_formatters.rb
|
186
|
-
- test/test_output_processor.rb
|
187
|
-
- test/test_consume_localization_file.rb
|
188
|
-
- test/test_consume_localization_archive.rb
|
189
200
|
- test/test_abstract_formatter.rb
|
190
201
|
- test/test_cli.rb
|
191
|
-
- test/
|
192
|
-
- test/
|
202
|
+
- test/test_consume_localization_archive.rb
|
203
|
+
- test/test_consume_localization_file.rb
|
204
|
+
- test/test_formatters.rb
|
193
205
|
- test/test_generate_all_localization_files.rb
|
194
206
|
- test/test_generate_localization_archive.rb
|
195
|
-
- test/
|
207
|
+
- test/test_generate_localization_file.rb
|
208
|
+
- test/test_output_processor.rb
|
196
209
|
- test/test_placeholders.rb
|
210
|
+
- test/test_twine_definition.rb
|
211
|
+
- test/test_twine_file.rb
|
197
212
|
- test/test_validate_twine_file.rb
|