flame-r18n 1.0.0 → 1.1.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 +9 -6
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3ab672711c49e894eca42bd80be0a348a007f81
4
- data.tar.gz: 2dfd1dfb5beca69259e6cbdf5a38e968895e2de9
3
+ metadata.gz: 883953fcd9390e5fbf7a482c6de232d4109fe371
4
+ data.tar.gz: 2c3de34304b2bba1b5d253247dcfe729a97b3b4c
5
5
  SHA512:
6
- metadata.gz: abb035608d7408040ef65776248777e9f28e057d8e7c8524f204035c43911a457aec197a0aba6601651fcb6b11aaddf1167b05b8e95f7cc9f60e474d427b1d9f
7
- data.tar.gz: 76b6f00d4aec61853f1f723e855b6bbfda194855133f68c29e608a4ecbc5927b718b758566cfc1c041de5641cc62fdf9ea14056a47af5dc19d2853315a1ec1a9
6
+ metadata.gz: 20193b690de320d2aec0e1743fce71c1ec736796ee88f7f822189ed0775fa3adec1de954c8c7904087601295bbc3c81696f5c94c3d5bd3ec8ccde1c65f5106fe
7
+ data.tar.gz: 44798d07232f99b28da44eebc5b70a37ab18c9615c401784f1e446d0102d8cfa4da679030a94b3fa8314eb207c6bd30c8ccd436568980facade3d9402f0509af
data/lib/flame/r18n.rb CHANGED
@@ -17,6 +17,7 @@ module Flame
17
17
 
18
18
  def execute(method)
19
19
  load_r18n
20
+ session[:locale] = preferred_locale || ::R18n.get.locale.code
20
21
  super
21
22
  end
22
23
 
@@ -33,18 +34,20 @@ module Flame
33
34
 
34
35
  def locales_from_env
35
36
  locales = ::R18n::I18n.parse_http(request.env['HTTP_ACCEPT_LANGUAGE'])
36
- if params[:locale]
37
- locales.insert(0, params[:locale])
38
- elsif session[:locale]
39
- locales.insert(0, session[:locale])
40
- end
37
+ locales = [preferred_locale] | locales if preferred_locale
38
+ locales
39
+ end
40
+
41
+ def preferred_locale
42
+ params[:locale] || session[:locale]
41
43
  end
42
44
 
43
45
  def load_r18n
44
46
  ::R18n.clear_cache! if config[:environment] == 'development'
45
47
 
46
48
  ::R18n.thread_set do
47
- ::R18n::I18n.default = config[:default_locale] if config[:default_locale]
49
+ default_locale = config[:default_locale]
50
+ ::R18n::I18n.default = default_locale if default_locale
48
51
 
49
52
  init_r18n
50
53
  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.0.0
4
+ version: 1.1.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-01-29 00:00:00.000000000 Z
11
+ date: 2016-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flame
@@ -53,7 +53,7 @@ extensions: []
53
53
  extra_rdoc_files: []
54
54
  files:
55
55
  - lib/flame/r18n.rb
56
- homepage: https://gitlab.com/AlexWayfer/flame-r18n
56
+ homepage: https://github.com/AlexWayfer/flame-r18n
57
57
  licenses:
58
58
  - MIT
59
59
  metadata: {}