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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1891efbb20cc81f439f20f30fb4d74586e09c2c9
4
- data.tar.gz: 2715fb01c3d8f203c791ffc55357469b077ad793
3
+ metadata.gz: 8ad319cbb6d09c6c0490394a5157c75c31068b0e
4
+ data.tar.gz: 7a3e850cb6f8e81296b1507402de29ca42352e6c
5
5
  SHA512:
6
- metadata.gz: 83421bf2129630b61d54543cfa484963415151301c345fd624febb67d65de937a45634173c54fb3017c5a3c3a3f95f3ab92ce1f814b147c99a560336f675f390
7
- data.tar.gz: 3a60ed45b7ee4764a8b809cb297e8a9b9a7bfa395ae683cd335009308b189a8bb56039e39e099abee88c5a637a3e1f9ac635b10bf575b5c40bdfc32b33b562ab
6
+ metadata.gz: f45211629474a502134398a2872e655bf44e77144b55971f24bd948d1657197de46e4de3be14788d34d7ebbc7321eb0bafae57db87ec20490d77aba3e54babe0
7
+ data.tar.gz: 888a73ce5a37e850a981f62bcd2c8d8d937a696d8948002ab5b6d157cce406899ad85192aabee2f6aae9d335ee4691442a6b450cc9c9cf79875a39a0896cdbc1
@@ -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
 
@@ -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 %@ or %1$@' => 'Android interpolation %s or %1$s'.
75
+ # Example: 'iOS interpolation %s or %1$s' => 'Android interpolation %@ or %1$@'.
76
76
  def replace_string_interpolations(string)
77
- string.gsub(/%([0-9]+\$)?@/, '%\\1s')
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
@@ -1,3 +1,3 @@
1
1
  module Aigu
2
- VERSION = '0.4'
2
+ VERSION = '0.4.1'
3
3
  end
@@ -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) %@\n " = " abc',
13
- 'STRING_4' => 'Value with an interpolation %@.',
14
- 'STRING_5' => 'Value with %@ interpolations %@.',
15
- 'STRING_6' => 'Value with an interpolation with an identifier %1$@.',
16
- 'STRING_7' => 'Value with %1$@ interpolations with an identifier %2$@.'
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) %s\\n " = " abc";
25
- "STRING_4" = "Value with an interpolation %s.";
26
- "STRING_5" = "Value with %s interpolations %s.";
27
- "STRING_6" = "Value with an interpolation with an identifier %1$s.";
28
- "STRING_7" = "Value with %1$s interpolations with an identifier %2$s.";
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: '0.4'
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-20 00:00:00.000000000 Z
12
+ date: 2014-11-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler