aigu 0.4 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/aigu/ios_exporter.rb +5 -5
- data/lib/aigu/ios_importer.rb +4 -2
- data/lib/aigu/version.rb +1 -1
- data/spec/aigu/ios_importer_spec.rb +10 -10
- 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: 8ad319cbb6d09c6c0490394a5157c75c31068b0e
|
4
|
+
data.tar.gz: 7a3e850cb6f8e81296b1507402de29ca42352e6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f45211629474a502134398a2872e655bf44e77144b55971f24bd948d1657197de46e4de3be14788d34d7ebbc7321eb0bafae57db87ec20490d77aba3e54babe0
|
7
|
+
data.tar.gz: 888a73ce5a37e850a981f62bcd2c8d8d937a696d8948002ab5b6d157cce406899ad85192aabee2f6aae9d335ee4691442a6b450cc9c9cf79875a39a0896cdbc1
|
data/lib/aigu/ios_exporter.rb
CHANGED
@@ -40,25 +40,25 @@ module Aigu
|
|
40
40
|
pattern = File.join(@input_directory, "#{@locale}.lproj", 'Localizable.strings')
|
41
41
|
filepath = Dir[pattern].first
|
42
42
|
|
43
|
-
assign_output_from_file!(filepath)
|
43
|
+
assign_output_from_file!(filepath, false)
|
44
44
|
|
45
45
|
pattern = File.join(@input_directory, "#{@locale}.lproj", 'Localizable.stringsdict')
|
46
46
|
filepath = Dir[pattern].first
|
47
47
|
|
48
|
-
assign_output_from_file!(filepath)
|
48
|
+
assign_output_from_file!(filepath, true)
|
49
49
|
|
50
50
|
@output
|
51
51
|
end
|
52
52
|
|
53
|
-
def assign_output_from_file!(filepath)
|
53
|
+
def assign_output_from_file!(filepath, is_dict)
|
54
54
|
if filepath
|
55
55
|
puts "Processing #{filepath}"
|
56
56
|
|
57
57
|
file_content = File.open(filepath, 'rt').read
|
58
58
|
|
59
|
-
@output.merge! parse_strings_file(file_content)
|
59
|
+
@output.merge! is_dict ? parse_stringsdict_file(file_content) : parse_strings_file(file_content)
|
60
60
|
else
|
61
|
-
puts 'Strings file not found'
|
61
|
+
puts is_dict ? 'Stringsdict file not found' : 'Strings file not found'
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
data/lib/aigu/ios_importer.rb
CHANGED
@@ -72,9 +72,9 @@ module Aigu
|
|
72
72
|
|
73
73
|
# This takes a string and replaces iOS interpolations to Android interpolations
|
74
74
|
# so that it is reusable across platforms.
|
75
|
-
# Example: 'iOS interpolation
|
75
|
+
# Example: 'iOS interpolation %s or %1$s' => 'Android interpolation %@ or %1$@'.
|
76
76
|
def replace_string_interpolations(string)
|
77
|
-
string.gsub(/%([0-9]+\$)
|
77
|
+
string.gsub(/%([0-9]+\$)?s/, '%\\1@')
|
78
78
|
end
|
79
79
|
|
80
80
|
def write_stringsdict_file(content)
|
@@ -82,6 +82,8 @@ module Aigu
|
|
82
82
|
|
83
83
|
# read file
|
84
84
|
file_path = File.join(@output_directory, "#{@locale}.lproj", 'Localizable.stringsdict')
|
85
|
+
return unless File.exist? file_path
|
86
|
+
|
85
87
|
puts "Updating #{file_path}"
|
86
88
|
|
87
89
|
file_content = File.open(file_path, 'rb:bom|utf-8').read
|
data/lib/aigu/version.rb
CHANGED
@@ -9,11 +9,11 @@ describe Aigu::IosImporter do
|
|
9
9
|
{
|
10
10
|
'STRING_1' => 'Value of string #1',
|
11
11
|
'STRING_2' => 'Value of string #2',
|
12
|
-
'STRING_3' => 'Value with special chars (%ld)
|
13
|
-
'STRING_4' => 'Value with an interpolation
|
14
|
-
'STRING_5' => 'Value with
|
15
|
-
'STRING_6' => 'Value with an interpolation with an identifier %1
|
16
|
-
'STRING_7' => 'Value with %1
|
12
|
+
'STRING_3' => 'Value with special chars (%ld) %s\n " = " abc',
|
13
|
+
'STRING_4' => 'Value with an interpolation %s.',
|
14
|
+
'STRING_5' => 'Value with %s interpolations %s.',
|
15
|
+
'STRING_6' => 'Value with an interpolation with an identifier %1$s.',
|
16
|
+
'STRING_7' => 'Value with %1$s interpolations with an identifier %2$s.'
|
17
17
|
}
|
18
18
|
end
|
19
19
|
|
@@ -21,11 +21,11 @@ describe Aigu::IosImporter do
|
|
21
21
|
<<-EOS.unindent
|
22
22
|
"STRING_1" = "Value of string #1";
|
23
23
|
"STRING_2" = "Value of string #2";
|
24
|
-
"STRING_3" = "Value with special chars (%ld)
|
25
|
-
"STRING_4" = "Value with an interpolation
|
26
|
-
"STRING_5" = "Value with
|
27
|
-
"STRING_6" = "Value with an interpolation with an identifier %1
|
28
|
-
"STRING_7" = "Value with %1
|
24
|
+
"STRING_3" = "Value with special chars (%ld) %@\\n " = " abc";
|
25
|
+
"STRING_4" = "Value with an interpolation %@.";
|
26
|
+
"STRING_5" = "Value with %@ interpolations %@.";
|
27
|
+
"STRING_6" = "Value with an interpolation with an identifier %1$@.";
|
28
|
+
"STRING_7" = "Value with %1$@ interpolations with an identifier %2$@.";
|
29
29
|
EOS
|
30
30
|
end
|
31
31
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aigu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rémi Prévost
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-11-
|
12
|
+
date: 2014-11-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|