twine 1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -8
- data/lib/twine/formatters/android.rb +1 -0
- 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/test_formatters.rb +18 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 381bd0d84850220b7ef1f8071a7398eb6c61e1f7c5bc057e5d96cd259f0f4578
|
4
|
+
data.tar.gz: 04a94d58790f88c95cf3ae000986f7f0df62165e2749cdc22e409fef391e2760
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f14b9de69dcd4a533fa5b769dc42a2601caec06d41e04470188fa3a59a3e418d53e2d2994bce2c119fec6fee8252a7d7e421b58cd90316e98a527422c6a19551
|
7
|
+
data.tar.gz: 60bc8c8c800d1f4b3e3b1664504052bf4dc561fe97f1e62b361943de6567e5a5d22902c98f485e03f1e651f76765a7951142c915576ee80dfc6ae933df12139c
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Twine
|
2
2
|
|
3
|
-
[
|
4
|
-
|
5
|
-
Twine is a command line tool for managing your strings and their translations. These are all stored in a master 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.
|
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
|
8
6
|
|
@@ -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,8 +209,8 @@ buildscript {
|
|
211
209
|
apply plugin: 'com.github.jruby-gradle.base'
|
212
210
|
|
213
211
|
dependencies {
|
214
|
-
/* NOTE: Set your
|
215
|
-
jrubyExec 'rubygems:twine:1.
|
212
|
+
/* NOTE: Set your preferred version of twine here. */
|
213
|
+
jrubyExec 'rubygems:twine:1.1'
|
216
214
|
}
|
217
215
|
|
218
216
|
task generateLocalizations (type: JRubyExec) {
|
@@ -65,6 +65,7 @@ module Twine
|
|
65
65
|
document.root.children.each do |child|
|
66
66
|
if child.is_a? REXML::Comment
|
67
67
|
content = child.string.strip
|
68
|
+
content.gsub!(/[\s]+/, ' ')
|
68
69
|
comment = content if content.length > 0 and not content.start_with?("SECTION:")
|
69
70
|
elsif child.is_a? REXML::Element
|
70
71
|
next unless child.name == 'string'
|
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
@@ -167,6 +167,24 @@ class TestAndroidFormatter < FormatterTest
|
|
167
167
|
assert_equal 'This is\n a string', @empty_twine_file.definitions_by_key["foo"].translations['en']
|
168
168
|
end
|
169
169
|
|
170
|
+
def test_read_multiline_comment
|
171
|
+
content = <<-EOCONTENT
|
172
|
+
<?xml version="1.0" encoding="utf-8"?>
|
173
|
+
<resources>
|
174
|
+
<!-- multiline
|
175
|
+
comment -->
|
176
|
+
<string name="foo">This is
|
177
|
+
a string</string>
|
178
|
+
</resources>
|
179
|
+
EOCONTENT
|
180
|
+
|
181
|
+
io = StringIO.new(content)
|
182
|
+
|
183
|
+
@formatter.read io, 'en'
|
184
|
+
|
185
|
+
assert_equal 'multiline comment', @empty_twine_file.definitions_by_key["foo"].comment
|
186
|
+
end
|
187
|
+
|
170
188
|
def test_read_html_tags
|
171
189
|
content = <<-EOCONTENT
|
172
190
|
<?xml version="1.0" encoding="utf-8"?>
|
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:
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastian Celis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-15 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
|
@@ -170,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
184
|
requirements:
|
171
185
|
- - ">="
|
172
186
|
- !ruby/object:Gem::Version
|
173
|
-
version: '2.
|
187
|
+
version: '2.6'
|
174
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
189
|
requirements:
|
176
190
|
- - ">="
|