l10n 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/l10n/column_translation.rb +12 -0
- data/lib/l10n/version.rb +1 -1
- metadata +2 -2
@@ -63,6 +63,18 @@ module L10n
|
|
63
63
|
translated_attributes.map(&:to_s).include?(attr_name.to_s)
|
64
64
|
end
|
65
65
|
|
66
|
+
def translated_column_name?(name)
|
67
|
+
!!column_language_code(name)
|
68
|
+
end
|
69
|
+
|
70
|
+
def column_language_code(name)
|
71
|
+
name = name.to_s
|
72
|
+
return I18n.default_language_code if translates?(name)
|
73
|
+
if match = name.match(/_([a-z]{2})\z/) and I18n.translation_language_codes.map(&:to_s).include?(code = match.captures.first)
|
74
|
+
code.to_sym
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
66
78
|
def translate_column_name(column_name_t, language_code = nil)
|
67
79
|
name = column_name_t.to_s
|
68
80
|
if name.ends_with?('_t') and translates?(name[0..-3])
|
data/lib/l10n/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: l10n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
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: 2013-10-
|
12
|
+
date: 2013-10-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|