air18n 0.4.2 → 0.4.3
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/lib/air18n/backend.rb +6 -2
- data/lib/air18n/phrase.rb +6 -8
- data/lib/air18n/version.rb +1 -1
- data/spec/lib/air18n/phrase_spec.rb +2 -0
- metadata +2 -2
data/lib/air18n/backend.rb
CHANGED
@@ -234,8 +234,9 @@ module Air18n
|
|
234
234
|
end
|
235
235
|
end
|
236
236
|
if store_default
|
237
|
-
phrase = Phrase.
|
238
|
-
if phrase
|
237
|
+
phrase = Phrase.where(:key => key).first
|
238
|
+
if phrase.present?
|
239
|
+
# A phrase with this key already exists; change its default text.
|
239
240
|
if (overrides_previous_default && phrase.value != default) ||
|
240
241
|
(!overrides_previous_default && phrase.value != default && phrase.value.blank?)
|
241
242
|
phrase.value = default
|
@@ -249,6 +250,9 @@ module Air18n
|
|
249
250
|
# again to create it next time automatically.
|
250
251
|
end
|
251
252
|
end
|
253
|
+
else
|
254
|
+
# Create the phrase for the first time.
|
255
|
+
Phrase.create(:key => key, :value => default)
|
252
256
|
end
|
253
257
|
|
254
258
|
@translation_data[locale][key] = default
|
data/lib/air18n/phrase.rb
CHANGED
@@ -59,14 +59,12 @@ module Air18n
|
|
59
59
|
-pt.locale.to_s.size
|
60
60
|
end
|
61
61
|
translations_with_language_last.each do |pt|
|
62
|
-
PhraseTranslation.
|
63
|
-
|
64
|
-
self
|
65
|
-
|
66
|
-
pt.
|
67
|
-
|
68
|
-
false, # do xss check? no
|
69
|
-
false # allow verification? no
|
62
|
+
PhraseTranslation.create(
|
63
|
+
:user_id => 0, # 0 means Automated
|
64
|
+
:phrase => self,
|
65
|
+
:key => self.key,
|
66
|
+
:locale => pt.locale,
|
67
|
+
:value => pt.value
|
70
68
|
)
|
71
69
|
end
|
72
70
|
end
|
data/lib/air18n/version.rb
CHANGED
@@ -52,6 +52,8 @@ describe Air18n::Phrase do
|
|
52
52
|
|
53
53
|
# Should have three translations auto-populated.
|
54
54
|
@phrase2.phrase_translations.size.should == 3
|
55
|
+
@phrase2.phrase_translations.first.phrase_id.should == @phrase2.id
|
56
|
+
@phrase2.phrase_translations.first.user_id.should == 0
|
55
57
|
|
56
58
|
@phrase2.latest_translation(:"zh-TW").id.should < @phrase2.latest_translation(:zh).id
|
57
59
|
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.4.
|
4
|
+
version: 0.4.3
|
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: 2013-03-
|
16
|
+
date: 2013-03-26 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: i18n
|