any2tmx 1.0.0 → 1.0.1
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/History.txt +4 -0
- data/lib/any2tmx/transforms/android_transform.rb +7 -2
- data/lib/any2tmx/transforms/json_transform.rb +7 -3
- data/lib/any2tmx/transforms/transform.rb +15 -2
- data/lib/any2tmx/transforms/yaml_transform.rb +10 -5
- data/lib/any2tmx/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e4a51f29495018028e773fa84c49a343cd82f9c8
|
|
4
|
+
data.tar.gz: 79770ee9937bd68ed1c5cf11e48b2683bd7f9680
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4e6e155c8a19e16f0e74d6c7644ceacca16bcbc3932eb85ac6071a7fb05bb0d2a47b3be9c6107edf491e3e6cf59eb01c55f07e88ca9f0cf72aad6b501b923523
|
|
7
|
+
data.tar.gz: 3c9527ee9fdfb1365d7d1585dbfb795c1c7faebd91a788d0145d4a5558cd26ea972f3915cbd0f64cf0750deba09ac58e85a5081e23eed8e234d5ece952c8efb5
|
data/History.txt
CHANGED
|
@@ -3,8 +3,13 @@ module Any2Tmx
|
|
|
3
3
|
class AndroidTransform < Transform
|
|
4
4
|
private
|
|
5
5
|
|
|
6
|
-
def
|
|
7
|
-
phrases =
|
|
6
|
+
def load_file(file, locale)
|
|
7
|
+
phrases = File.read(file)
|
|
8
|
+
load(contents, locale)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def load(contents, locale)
|
|
12
|
+
contents = Any2Tmx::AndroidXmlParser.parse(contents)
|
|
8
13
|
traversable = Any2Tmx::Traversable.new(phrases)
|
|
9
14
|
Any2Tmx::PhraseSet.new(traversable, locale)
|
|
10
15
|
end
|
|
@@ -5,9 +5,13 @@ module Any2Tmx
|
|
|
5
5
|
class JsonTransform < Transform
|
|
6
6
|
private
|
|
7
7
|
|
|
8
|
-
def
|
|
9
|
-
phrases =
|
|
10
|
-
|
|
8
|
+
def load_file(file, locale)
|
|
9
|
+
phrases = File.read(file)
|
|
10
|
+
load(phrases)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def load(contents, locale)
|
|
14
|
+
traversable = Any2Tmx::Traversable.new(JSON.parse(contents))
|
|
11
15
|
Any2Tmx::PhraseSet.new(traversable, locale)
|
|
12
16
|
end
|
|
13
17
|
end
|
|
@@ -8,8 +8,8 @@ module Any2Tmx
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def result
|
|
11
|
-
source =
|
|
12
|
-
target =
|
|
11
|
+
source = read(options.source, options.source_locale)
|
|
12
|
+
target = read(options.target, options.target_locale)
|
|
13
13
|
count = 0
|
|
14
14
|
zipped = source.zip(target) { count += 1 }
|
|
15
15
|
Result.new(source, target, zipped, count)
|
|
@@ -17,6 +17,19 @@ module Any2Tmx
|
|
|
17
17
|
|
|
18
18
|
private
|
|
19
19
|
|
|
20
|
+
def read(location_or_contents, locale)
|
|
21
|
+
if File.exist?(location_or_contents)
|
|
22
|
+
load_file(location_or_contents, locale)
|
|
23
|
+
else
|
|
24
|
+
load(location_or_contents, locale)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def load_file(file, locale)
|
|
29
|
+
raise NotImplementedError,
|
|
30
|
+
"#{__method__} must be defined in derived classes"
|
|
31
|
+
end
|
|
32
|
+
|
|
20
33
|
def load(file, locale)
|
|
21
34
|
raise NotImplementedError,
|
|
22
35
|
"#{__method__} must be defined in derived classes"
|
|
@@ -5,14 +5,19 @@ module Any2Tmx
|
|
|
5
5
|
class YamlTransform < Transform
|
|
6
6
|
private
|
|
7
7
|
|
|
8
|
-
def
|
|
9
|
-
phrases =
|
|
8
|
+
def load_file(file, locale)
|
|
9
|
+
phrases = File.read(file)
|
|
10
|
+
load(phrases, locale)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def load(contents, locale)
|
|
14
|
+
contents = YAML.load(contents)
|
|
10
15
|
|
|
11
|
-
if
|
|
12
|
-
|
|
16
|
+
if contents.include?(locale)
|
|
17
|
+
contents = contents[locale]
|
|
13
18
|
end
|
|
14
19
|
|
|
15
|
-
traversable = Any2Tmx::Traversable.new(
|
|
20
|
+
traversable = Any2Tmx::Traversable.new(contents)
|
|
16
21
|
Any2Tmx::PhraseSet.new(traversable, locale)
|
|
17
22
|
end
|
|
18
23
|
end
|
data/lib/any2tmx/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: any2tmx
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Cameron Dutro
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-02-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: xml-write-stream
|