air18n 0.1.41 → 0.1.42
Sign up to get free protection for your applications and to get access to all the features.
- data/config/colonial_spelling_variants.yml +13 -9
- data/lib/air18n/class_methods.rb +16 -6
- data/lib/air18n/phrase_translation.rb +0 -4
- data/lib/air18n/prim_and_proper.rb +5 -3
- data/lib/air18n/version.rb +1 -1
- data/spec/lib/air18n/air18n_spec.rb +1 -0
- data/spec/lib/air18n/phrase_translation_spec.rb +2 -2
- metadata +2 -2
@@ -1,12 +1,16 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
1
|
+
# List of American-to-British spelling variants.
|
2
|
+
#
|
3
|
+
# This list is made with
|
4
|
+
# lib/tasks/list_american_to_british_spelling_variants.rake.
|
5
|
+
#
|
6
|
+
# It contains words with general spelling variation patterns:
|
7
|
+
# [trave]led/lled, [real]ize/ise, [flav]or/our, [cent]er/re, plus
|
8
|
+
# and these extras:
|
9
|
+
# learned/learnt, practices/practises, airplane/aeroplane,
|
10
|
+
# inquire/enquire, specialties/specialities, inquiry/enquiry,
|
11
|
+
# artifact/artefact, program/programme, livable/liveable, among/amongst,
|
12
|
+
# spelled/spelt, judgment/judgement, defense/defence, fulfill/fulfil,
|
13
|
+
# spilled/spilt
|
10
14
|
|
11
15
|
sectarianizes: sectarianises
|
12
16
|
neutralization: neutralisation
|
data/lib/air18n/class_methods.rb
CHANGED
@@ -44,18 +44,28 @@ module Air18n
|
|
44
44
|
# Like ActionView::Helpers::TextHelper#pluralize, except requires that
|
45
45
|
# 'count' be a real number, not a string.
|
46
46
|
#
|
47
|
-
# ActionView::Helpers::TextHelper#pluralize is inherently English-centric
|
48
|
-
#
|
47
|
+
# ActionView::Helpers::TextHelper#pluralize is inherently English-centric.
|
48
|
+
# So this method is too, and assumes that the default locale's plural forms
|
49
49
|
# are like "%{smart_count} count-is-one-form;%{smart_count} everything-else-form".
|
50
|
+
#
|
51
|
+
# Pass in nil for the count if you want to get the default text (for
|
52
|
+
# example, if you will be interpolating the count into the text in the
|
53
|
+
# front-end.) For example:
|
54
|
+
# I18n.pluralize(nil, 'Review')
|
55
|
+
# => '%{smart_count} Review||||%{smart_count} Reviews'
|
50
56
|
def pluralize(count, singular, plural=nil)
|
51
57
|
raise TypeError if count.is_a?(String)
|
52
58
|
default_text = "%{smart_count} #{singular}#{SmartCount::DELIMITER}%{smart_count} #{plural || singular.pluralize}"
|
53
59
|
key = "shared.pluralize.#{singular}"
|
54
|
-
|
60
|
+
if count == nil
|
61
|
+
translate(key, :default => default_text, :suppress_ct => true)
|
62
|
+
else
|
63
|
+
translate(key, :default => default_text, :smart_count => count, :suppress_ct => true)
|
64
|
+
end
|
55
65
|
end
|
56
66
|
|
57
|
-
# For
|
58
|
-
# part (like :en or :pt).
|
67
|
+
# For given locale (like :en, :en-GB, :pt-PT, or "en", "en-GB", "pt-PT"),
|
68
|
+
# returns the "language" part (like :en or :pt).
|
59
69
|
# If locale is invalid or nil, returns the default language.
|
60
70
|
def language_from_locale locale
|
61
71
|
tags = I18n::Locale::Tag.tag(locale)
|
@@ -170,7 +180,7 @@ module Air18n
|
|
170
180
|
# always the last one in the returned list, will be excluded.
|
171
181
|
#
|
172
182
|
# For example, fallbacks_for(:"pt-BR") is [:"pt-BR", :pt, :en] with
|
173
|
-
# exclude_default
|
183
|
+
# :exclude_default => false and [:"pt-BR", :pt] with :exclude_default => true.
|
174
184
|
def fallbacks_for(the_locale, opts = {})
|
175
185
|
# We dup() because otherwise the fallbacks hash might itself be modified
|
176
186
|
# by the user of this method, and that would be terrible.
|
@@ -465,9 +465,6 @@ module Air18n
|
|
465
465
|
if compare_to == 0
|
466
466
|
proportion_translated = 0.0
|
467
467
|
proportion_verified = 0.0
|
468
|
-
|
469
|
-
LoggingHelper.error("Word counts for weird pair: #{translation_pair.inspect}")
|
470
|
-
LoggingHelper.error("distance: #{distance.inspect}, compare to: #{compare_to.inspect}")
|
471
468
|
else
|
472
469
|
proportion_translated = [distance.to_f / compare_to.to_f, 1.0].min
|
473
470
|
proportion_verified = 1.0 - proportion_translated
|
@@ -549,7 +546,6 @@ module Air18n
|
|
549
546
|
}
|
550
547
|
|
551
548
|
pt.payment_details = payment_details.to_json
|
552
|
-
LoggingHelper.info "saving payment details: "
|
553
549
|
pt.save
|
554
550
|
end
|
555
551
|
|
@@ -1,7 +1,9 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# provided.
|
1
|
+
# Automatic conversion of one locale to another where it is possible, like
|
2
|
+
# American to British English.
|
4
3
|
module Air18n
|
4
|
+
# Class for converting between text between similar locales.
|
5
|
+
# Right now only conversion between American English -> British, Canadian,
|
6
|
+
# Australian, New Zealand variations is provided.
|
5
7
|
class PrimAndProper
|
6
8
|
def initialize
|
7
9
|
@converters = { :en => { :"en-AU" => AmericanToAustralian.new,
|
data/lib/air18n/version.rb
CHANGED
@@ -145,6 +145,7 @@ describe Air18n do
|
|
145
145
|
I18n.pluralize(1, 'Review').should == '1 Review'
|
146
146
|
I18n.pluralize(2, 'Review').should == '2 Reviews'
|
147
147
|
I18n.pluralize(123.5, 'Review').should == '123.5 Reviews'
|
148
|
+
I18n.pluralize(nil, 'Review').should == '%{smart_count} Review||||%{smart_count} Reviews'
|
148
149
|
end
|
149
150
|
|
150
151
|
it 'should raise an error if count is a string' do
|
@@ -313,7 +313,7 @@ describe Air18n::PhraseTranslation do
|
|
313
313
|
verification = FactoryGirl.create(:phrase_translation, :value => 'oogie boogie boo', :phrase => @phrase1, :user_id => @user1, :source_hash => 'new default text', :source_word_count => 13, :is_verification => true, :created_at => Date.new(2012, 10, 5))
|
314
314
|
end
|
315
315
|
|
316
|
-
data = Air18n::PhraseTranslation.translator_activity_data_master(0, :since => Date.new(2012, 9, 1))
|
316
|
+
data = Air18n::PhraseTranslation.translator_activity_data_master(0, :since => Date.new(2012, 9, 1), :to => Date.new(2012, 10, 1))
|
317
317
|
|
318
318
|
# Example Scenario:
|
319
319
|
# Translator A translates phrase Y when it is 8 English words
|
@@ -813,7 +813,7 @@ describe Air18n::PhraseTranslation do
|
|
813
813
|
end
|
814
814
|
|
815
815
|
it 'should keep track of translated and verified word count in v3 regime' do
|
816
|
-
data = Air18n::PhraseTranslation.translator_activity_data_master
|
816
|
+
data = Air18n::PhraseTranslation.translator_activity_data_master(0, :since => Date.new(2012, 11, 1), :to => Date.new(2012, 12, 1))
|
817
817
|
@golden_monthly_activity.each do |a|
|
818
818
|
data.should include(a)
|
819
819
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: air18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.42
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2012-
|
16
|
+
date: 2012-12-05 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: i18n
|