titlezilla 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/titlezilla/translator.rb +16 -3
- data/lib/titlezilla/version.rb +1 -1
- data/test/translator_test.rb +6 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eecbd86111fab30e1ca161d993a104d1834572c
|
4
|
+
data.tar.gz: baa72c194765f3d389eb7a6c6f78644c1c175cfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89695306ef894bbc08471cf924b309c6ca98100c19c83f94a4275b0bcbf8f00abee049cc69cfb495d0ce2c83981ac2218b2fd648578649b057e2267f7f500757
|
7
|
+
data.tar.gz: 962b3735897a7f99a0bb330d90c2656d0a751bf81b8d85b2176f791cb254c4f76725d7945e4ecd257e30e7764d0ce6129c1026680b748d56637f4b96e81ea54e
|
@@ -19,7 +19,7 @@ module Titlezilla
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def application_title
|
22
|
-
@application_title ||=
|
22
|
+
@application_title ||= reverse_lookup('application')
|
23
23
|
end
|
24
24
|
|
25
25
|
def meta_title
|
@@ -34,12 +34,25 @@ module Titlezilla
|
|
34
34
|
if parts.size > 1
|
35
35
|
[parts[(0...-1)], parts[-1]]
|
36
36
|
else
|
37
|
-
[
|
37
|
+
[[], parts[0].to_s.freeze]
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
def lookup(*key)
|
42
|
-
|
42
|
+
lookup_with_namespace(key, namespace)
|
43
|
+
end
|
44
|
+
|
45
|
+
def reverse_lookup(*key)
|
46
|
+
title_namespace = namespace.dup
|
47
|
+
begin
|
48
|
+
title = lookup_with_namespace(key, title_namespace)
|
49
|
+
return title if title
|
50
|
+
title_namespace.pop
|
51
|
+
end while title_namespace.size >= 0
|
52
|
+
end
|
53
|
+
|
54
|
+
def lookup_with_namespace(keys, namespace)
|
55
|
+
t_key = [:titles, namespace, keys].flatten.compact.join('.')
|
43
56
|
i18n_set?(t_key) ? I18n.t(t_key, context) : nil
|
44
57
|
end
|
45
58
|
|
data/lib/titlezilla/version.rb
CHANGED
data/test/translator_test.rb
CHANGED
@@ -70,6 +70,12 @@ module Titlezilla
|
|
70
70
|
t = Translator.new('admin/main', :index)
|
71
71
|
t.application_title.must_equal 'App'
|
72
72
|
end
|
73
|
+
|
74
|
+
it 'should lookup application title when no namespaced app title provided' do
|
75
|
+
load_translations({ application: 'App' })
|
76
|
+
t = Translator.new('admin/main', :index)
|
77
|
+
t.application_title.must_equal 'App'
|
78
|
+
end
|
73
79
|
end
|
74
80
|
|
75
81
|
describe '#meta_title' do
|