grosser-fast_gettext 0.4.14 → 0.4.15

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/CHANGELOG CHANGED
@@ -1,3 +1,4 @@
1
+ 0.4.14 -- "" is translated as "", not as gettext meta information
1
2
  0.4.0 -- pluralisation_rules is no longer stored in each repository, only retrived. Added Chain and Logger repository.
2
3
  0.3.6 -- FastGettext.default_locale=
3
4
  0.3.5 -- FastGettext.default_text_domain=
@@ -117,12 +117,16 @@ Advanced features
117
117
  Pluralisation rules can be set directly via a lambda (see specs/), or by using the Gettext
118
118
  plural definition (see spec/locale/en/test_plural.po or [Plural expressions for all languages](http://translate.sourceforge.net/wiki/l10n/pluralforms).
119
119
 
120
+
120
121
  ###default_text_domain
121
122
  If you only use one text domain, setting `FastGettext.default_text_domain = 'app'`
122
123
  is sufficient and no more `text_domain=` is needed
123
124
 
124
125
  ###default_locale
125
- If the simple rule of "first `availble_locale` or 'en'" is not suficcient for you, simply set `FastGettext.default_locale = 'de'`.
126
+ If the simple rule of "first `availble_locale` or 'en'" is not suficcient for you, set `FastGettext.default_locale = 'de'`.
127
+
128
+ ###default_available_locales
129
+ Fallback when no available_locales are set
126
130
 
127
131
  ###Chains
128
132
  You can use any number of repositories to find a translation. Simply add them to a chain and when
@@ -174,6 +178,7 @@ Mo/Po-file parsing from Masao Mutoh, see vendor/README
174
178
 
175
179
  ###Contributors
176
180
  - [geekq](http://www.innoq.com/blog/vd)
181
+ - Rudolf Gavlas
177
182
 
178
183
  [Michael Grosser](http://pragmatig.wordpress.com)
179
184
  grosser.michael@gmail.com
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.14
1
+ 0.4.15
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{fast_gettext}
5
- s.version = "0.4.14"
5
+ s.version = "0.4.15"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Michael Grosser"]
9
- s.date = %q{2009-08-10}
9
+ s.date = %q{2009-09-01}
10
10
  s.email = %q{grosser.michael@gmail.com}
11
11
  s.extra_rdoc_files = [
12
12
  "README.markdown"
@@ -23,23 +23,28 @@ module FastGettext
23
23
  end
24
24
  private :_locale, :_locale=
25
25
 
26
- def text_domain
27
- Thread.current[:fast_gettext_text_domain] || default_text_domain
26
+
27
+ def available_locales
28
+ Thread.current[:fast_gettext_available_locales] || default_available_locales
28
29
  end
29
30
 
30
- def pluralisation_rule
31
- Thread.current[:fast_gettext_pluralisation_rule] || current_repository.pluralisation_rule || lambda{|i| i!=1}
31
+ # == cattr_accessor :default_available_locales
32
+ @@default_available_locales = nil
33
+ def default_available_locales=(avail_locales)
34
+ @@default_available_locales = avail_locales
35
+ update_current_cache
32
36
  end
33
37
 
34
- def current_cache
35
- Thread.current[:fast_gettext_current_cache] || {}
38
+ def default_available_locales
39
+ @@default_available_locales
36
40
  end
37
41
 
38
- def current_cache=(cache)
39
- Thread.current[:fast_gettext_current_cache] = cache
42
+
43
+ def text_domain
44
+ Thread.current[:fast_gettext_text_domain] || default_text_domain
40
45
  end
41
46
 
42
- #-> cattr_accessor :default_text_domain
47
+ # == cattr_accessor :default_text_domain
43
48
  @@default_text_domain = nil
44
49
  def default_text_domain=(domain)
45
50
  @@default_text_domain = domain
@@ -50,6 +55,19 @@ module FastGettext
50
55
  @@default_text_domain
51
56
  end
52
57
 
58
+
59
+ def pluralisation_rule
60
+ Thread.current[:fast_gettext_pluralisation_rule] || current_repository.pluralisation_rule || lambda{|i| i!=1}
61
+ end
62
+
63
+ def current_cache
64
+ Thread.current[:fast_gettext_current_cache] || {}
65
+ end
66
+
67
+ def current_cache=(cache)
68
+ Thread.current[:fast_gettext_current_cache] = cache
69
+ end
70
+
53
71
  #global, since re-parsing whole folders takes too much time...
54
72
  @@translation_repositories={}
55
73
  def translation_repositories
@@ -96,6 +96,28 @@ describe 'Storage' do
96
96
  end
97
97
  end
98
98
 
99
+ describe :default_available_locales do
100
+ after do
101
+ self.default_available_locales = nil
102
+ end
103
+
104
+ it "stores default_available_locales non-thread-safe" do
105
+ thread_save(:default_available_locales, 'xx').should == false
106
+ end
107
+
108
+ it "uses default_available_locales when available_locales is not set" do
109
+ self.available_locales = nil
110
+ self.default_available_locales = 'x'
111
+ available_locales.should == 'x'
112
+ end
113
+
114
+ it "does not use default when available_locales is set" do
115
+ self.available_locales = 'x'
116
+ self.default_available_locales = 'y'
117
+ available_locales.should == 'x'
118
+ end
119
+ end
120
+
99
121
  describe :locale do
100
122
  it "stores everything as long as available_locales is not set" do
101
123
  self.available_locales = nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grosser-fast_gettext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.14
4
+ version: 0.4.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-10 00:00:00 -07:00
12
+ date: 2009-09-01 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -84,7 +84,6 @@ files:
84
84
  - vendor/string.rb
85
85
  has_rdoc: false
86
86
  homepage: http://github.com/grosser/fast_gettext
87
- licenses:
88
87
  post_install_message:
89
88
  rdoc_options:
90
89
  - --charset=UTF-8
@@ -105,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
104
  requirements: []
106
105
 
107
106
  rubyforge_project:
108
- rubygems_version: 1.3.5
107
+ rubygems_version: 1.2.0
109
108
  signing_key:
110
109
  specification_version: 3
111
110
  summary: A simple, fast and threadsafe implementation of GetText