vocab 0.1.1 → 0.1.2

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.
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  *.gem
2
+ *.rvmrc
2
3
  *.tmp
3
4
  .bundle
4
5
  Gemfile.lock
@@ -1,8 +1,8 @@
1
1
  module Vocab
2
2
  module Merger
3
3
  class Android < Base
4
- FORMAT_PATTERN = /%(.+?)\b/
5
- ARG_PATTERN = /\$(.+?)\b/
4
+ FORMAT_PATTERN = /%\w/
5
+ ARG_PATTERN = /\$[a-zA-Z]/
6
6
 
7
7
  def initialize( locales_dir = nil, updates_dir = nil )
8
8
  @locales_dir = locales_dir || 'res'
@@ -72,7 +72,7 @@ module Vocab
72
72
  new_value.each do |inner_key,inner_value|
73
73
  if ( @english_plurals[ key ][ inner_key ].to_s.scan( FORMAT_PATTERN ) != inner_value.to_s.scan( FORMAT_PATTERN ) ) ||
74
74
  ( @english_plurals[ key ][ inner_key ].to_s.scan( ARG_PATTERN ) != inner_value.to_s.scan( ARG_PATTERN ) )
75
- Vocab.ui.warn( "Format string mismatch for key #{key}, quantity #{inner_key} while merging #{path}. \n English: #{@english_plurals[ key ][ inner_key ]} \n Translation: #{new_value[ inner_key ]}" )
75
+ Vocab.ui.warn( "Format string mismatch for key #{key}, quantity #{inner_key} while merging #{path}. \n English: #{@english_plurals[ key ][ inner_key ]} \n Translation: #{new_value[ inner_key ]}\n\n" )
76
76
  end
77
77
  end
78
78
  end
@@ -80,7 +80,7 @@ module Vocab
80
80
  def string_format_changed?( key, new_value, path )
81
81
  if ( @english_strings[ key ].to_s.scan( FORMAT_PATTERN ) != new_value.to_s.scan( FORMAT_PATTERN ) ) ||
82
82
  ( @english_strings[ key ].to_s.scan( ARG_PATTERN ) != new_value.to_s.scan( ARG_PATTERN ) )
83
- Vocab.ui.warn( "Format string mismatch for key #{key} while merging #{path}. \n English: #{@english_strings[ key ]} \n Translation: #{new_value}" )
83
+ Vocab.ui.warn( "Format string mismatch for key #{key} while merging #{path}. \n English: #{@english_strings[ key ]} \n Translation: #{new_value}\n\n" )
84
84
  end
85
85
  end
86
86
 
@@ -1,3 +1,3 @@
1
1
  module Vocab
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -8,6 +8,9 @@
8
8
  <string name="delete">Deletee %2$d</string>
9
9
  <string name="not_in_es">This key not in spanish</string>
10
10
  <string name="debug_key">Should be ignored</string>
11
+ <string name="price">Alles zu einem Preis von 3,50 USD pro Monat.</string>
12
+ <string name="free">%s의 주간 무료 앱!</string>
13
+ <string name="guarantee">Rimborso garantito al 100%!</string>
11
14
 
12
15
  <plurals name="user_count">
13
16
  <item quantity="one">1 user</item>
@@ -8,6 +8,10 @@
8
8
  <string name="delete">Delete %1$d</string>
9
9
  <string name="not_in_es">This key not in spanish</string>
10
10
  <string name="debug_key">Should be ignored</string>
11
+ <string name="price">All this for only $3.50 a month!</string>
12
+ <string name="free">%s\'s free weekly app!</string>
13
+ <string name="guarantee">100% money back guarantee!</string>
14
+
11
15
 
12
16
  <plurals name="user_count">
13
17
  <item quantity="one">1 user</item>
@@ -1 +1,2 @@
1
- bom:
1
+ bom:
2
+ test: "bogus"
@@ -10,7 +10,7 @@ describe "Vocab::Extractor::Android" do
10
10
 
11
11
  it "extracts hash of current string translations" do
12
12
  actual = Vocab::Extractor::Android.current_strings( @locale )
13
- actual.should eql( { "app_name" =>"Kid Mode",
13
+ actual.should include( { "app_name" =>"Kid Mode",
14
14
  "delete" =>"Delete %1$d",
15
15
  "cancel" =>"Cancel",
16
16
  "app_current"=>"current",
@@ -42,15 +42,34 @@ describe "Vocab::Merger::Android" do
42
42
  describe "check_matching_format_strings" do
43
43
  it 'warns about format string changes in singular strings' do
44
44
  @merger = Vocab::Merger::Android.new( @merge_dir, @update_dir )
45
- Vocab.ui.should_receive( :warn ).with( "Format string mismatch for key delete while merging #{@merge_dir}/values-fr/strings.xml. \n English: Delete %1$d \n Translation: Deletee %2$d" )
45
+ Vocab.ui.should_receive( :warn ).with( "Format string mismatch for key delete while merging #{@merge_dir}/values-fr/strings.xml. \n English: Delete %1$d \n Translation: Deletee %2$d\n\n" )
46
46
  @merger.check_matching_format_strings( 'delete', "Deletee %2$d", "#{@merge_dir}/values-fr/strings.xml", :string_format_changed? )
47
47
  end
48
48
 
49
49
  it 'warns about format string changes in plurals' do
50
50
  @merger = Vocab::Merger::Android.new( @merge_dir, @update_dir )
51
- Vocab.ui.should_receive( :warn ).with( "Format string mismatch for key user_count, quantity many while merging #{@merge_dir}/values-fr/strings.xml. \n English: %d users \n Translation: %f users" )
51
+ Vocab.ui.should_receive( :warn ).with( "Format string mismatch for key user_count, quantity many while merging #{@merge_dir}/values-fr/strings.xml. \n English: %d users \n Translation: %f users\n\n" )
52
52
  @merger.check_matching_format_strings( 'user_count', { "one" => "1 user", "many" => "%f users" }, "#{@merge_dir}/values-fr/strings.xml", :plural_format_changed? )
53
53
  end
54
+
55
+
56
+ it 'does not warn about $ in currency' do
57
+ @merger = Vocab::Merger::Android.new( @merge_dir, @update_dir )
58
+ Vocab.ui.should_not_receive( :warn )
59
+ @merger.check_matching_format_strings( 'price', "Alles zu einem Preis von 3,50 USD pro Monat.", "#{@merge_dir}/values-fr/strings.xml", :string_format_changed? )
60
+ end
61
+
62
+ it 'does not warn about % as actual percent sign' do
63
+ @merger = Vocab::Merger::Android.new( @merge_dir, @update_dir )
64
+ Vocab.ui.should_not_receive( :warn )
65
+ @merger.check_matching_format_strings( 'guarantee', "Rimborso garantito al 100%!", "#{@merge_dir}/values-fr/strings.xml", :string_format_changed? )
66
+ end
67
+
68
+ it 'only checks for one character after %' do
69
+ @merger = Vocab::Merger::Android.new( @merge_dir, @update_dir )
70
+ Vocab.ui.should_not_receive( :warn )
71
+ @merger.check_matching_format_strings( 'free', "%s의 주간 무료 앱!", "#{@merge_dir}/values-fr/strings.xml", :string_format_changed? )
72
+ end
54
73
  end
55
74
 
56
75
  describe 'merge_file' do
@@ -114,7 +133,7 @@ describe "Vocab::Merger::Android" do
114
133
 
115
134
  it 'fetches the english keys' do
116
135
  merger = Vocab::Merger::Android.new( @merge_dir )
117
- keys = ["app_name", "delete", "cancel", "app_current", "not_in_es", "pd_app_name"]
136
+ keys = ["app_name", "delete", "cancel", "app_current", "not_in_es", "pd_app_name", "free", "guarantee", "price" ]
118
137
  merger.string_keys.should =~ keys
119
138
  end
120
139
 
@@ -6,7 +6,7 @@ describe 'Vocab::Translator::Android' do
6
6
 
7
7
  it 'returns the english keys for a locales dir' do
8
8
  locales_dir = "#{vocab_root}/spec/data/android/locales"
9
- expected = ["app_name", "delete", "cancel", "app_current", "not_in_es", "pd_app_name"]
9
+ expected = ["app_name", "delete", "cancel", "app_current", "not_in_es", "pd_app_name", "free", "guarantee", "price"]
10
10
  Vocab::Translator::Android.string_keys( locales_dir ).should =~ expected
11
11
  end
12
12
 
@@ -15,7 +15,7 @@ describe "Vocab::Validator::Android" do
15
15
 
16
16
  it 'returns a hash containing the missing keys' do
17
17
  result = @validator.validate_file( @path )
18
- result[ :missing ].should eql( [ "cancel", "delete", "not_in_es" ] )
18
+ result[ :missing ].should eql( [ "cancel", "delete", "free", "guarantee", "not_in_es", "price" ] )
19
19
  end
20
20
 
21
21
  it 'returns a hash containing the extra keys' do
@@ -11,7 +11,7 @@ describe "Vocab::Validator::Rails" do
11
11
 
12
12
  it "complains about yml files with leading BOM characters" do
13
13
  File.open( "#{@locales_dir}/bom.yml", "w+" ) { |f| f.write( "\xEF\xBB\xBF".force_encoding("UTF-8") ) }
14
- File.open( "#{@locales_dir}/bom.yml", "a" ) { |f| f.write( "bom:" ) }
14
+ File.open( "#{@locales_dir}/bom.yml", "a" ) { |f| f.write( "bom:\n test: \"bogus\"" ) }
15
15
 
16
16
  bom_regex = "\xEF\xBB\xBF".force_encoding("UTF-8")
17
17
  File.open( "#{@locales_dir}/bom.yml" ) { |f| f.read }.force_encoding( "UTF-8" ).match( bom_regex ).should be_true
@@ -99,4 +99,4 @@ describe "Vocab::Validator::Rails" do
99
99
 
100
100
  end
101
101
 
102
- end
102
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vocab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-21 00:00:00.000000000 Z
12
+ date: 2013-02-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: i18n
@@ -321,3 +321,4 @@ test_files:
321
321
  - spec/validator/base_spec.rb
322
322
  - spec/validator/rails_spec.rb
323
323
  - spec/vocab_spec.rb
324
+ has_rdoc: