flame-r18n 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/flame/r18n.rb +11 -11
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8daf054a8ea79ca57a77ae6e3e5e240bfa94627d
4
- data.tar.gz: 01775fe27ded5a3d85ead697773fbd51c08327fd
3
+ metadata.gz: c5fe2146f9f4b7a918d01b3686420378f58ecc2a
4
+ data.tar.gz: 18f7f0478fd922587f1aa7dd6a24d56a5b7037a7
5
5
  SHA512:
6
- metadata.gz: 5741b0494fdfb8cef18c0b54e5790ba9ed4f681a6e03c5b0d9d639683f4869af0c26ac1ed0baa7e79944a6d3ef641fd7c6efaa40d53c641a1cd095a052ebdeed
7
- data.tar.gz: e364419d620577191e8e6c4a2a1726057e9e73efeb9d0061c7ecff557729c08ffe1405a0aa4ccaff4332180aef81684c235ffabbab2b6e6ff82a2dbfca8bf56b
6
+ metadata.gz: 43072cf755dac06280a4a38910701573f09ce97af58178b21b6937aa99c57d3c42650e8f0673de9b3dcdc1a8cad5d767395470e565526ef62b800caa4f7a3401
7
+ data.tar.gz: 93201ac10ad284aee53450e6b377bed8ee54d4c06c794a62f0458179b57a945a72c000028dafe585a4a1740a36febaf50fd472fb64c4d7ffbb58a8f55b248599
data/lib/flame/r18n.rb CHANGED
@@ -17,27 +17,27 @@ module Flame
17
17
 
18
18
  def execute(method)
19
19
  load_r18n
20
- session[:locale] = (
21
- preferred_locale || ::R18n.get.locale.code
22
- ).gsub(/^\W+|\W+$/, '')
20
+ session[:locale] = ::R18n.get.locale.code
23
21
  super
24
22
  end
25
23
 
26
- private
27
-
28
- def init_r18n
24
+ def init_r18n(locale)
29
25
  ::R18n::I18n.new(
30
- locales_from_env,
26
+ Array(locale) | locales_from_env,
31
27
  ::R18n.default_places,
32
28
  off_filters: :untranslated,
33
29
  on_filters: :untranslated_html
34
30
  )
35
31
  end
36
32
 
33
+ def thread_locale=(locale)
34
+ ::R18n.thread_set init_r18n locale
35
+ end
36
+
37
+ private
38
+
37
39
  def locales_from_env
38
- locales = ::R18n::I18n.parse_http(request.env['HTTP_ACCEPT_LANGUAGE'])
39
- locales = [preferred_locale] | locales if preferred_locale
40
- locales
40
+ ::R18n::I18n.parse_http(request.env['HTTP_ACCEPT_LANGUAGE'])
41
41
  end
42
42
 
43
43
  def preferred_locale
@@ -52,7 +52,7 @@ module Flame
52
52
  default_locale = config[:default_locale]
53
53
  ::R18n::I18n.default = default_locale if default_locale
54
54
 
55
- init_r18n
55
+ init_r18n preferred_locale
56
56
  end
57
57
  end
58
58
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flame-r18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Popov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-08 00:00:00.000000000 Z
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flame