translations_ennder 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -12,3 +12,6 @@
12
12
 
13
13
  == 1.0.0 / 2011-01-10
14
14
  * Ajout méthode set_locale au helper de l'appli
15
+
16
+ == 1.0.1 / 2011-01-10
17
+ * set_locale : Helper vers extension ApplicationController
@@ -9,36 +9,4 @@ module ApplicationHelper
9
9
  label(true, object_name, method, "<b>#{text}</b> :", true, options)
10
10
  end
11
11
  end
12
-
13
- ########################################################
14
- # Recherche et M-À-J la locale #
15
- # depuis les params de requête, la session, la requête #
16
- # JBA 2010-09-07 #
17
- ########################################################
18
- def set_locale
19
- if (params[:locale] and params[:locale].match /^(en|fr)$/)
20
- I18n.locale = params[:locale]
21
- elsif session[:locale].nil?
22
- if request.env['HTTP_ACCEPT_LANGUAGE'].blank?
23
- #2011-01-05 Vérif° supplémentaire
24
- _http_lang = ''
25
- else
26
- _http_lang = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
27
- end
28
-
29
- if _http_lang.match /^(en|fr)$/
30
- I18n.locale = _http_lang
31
- else
32
- I18n.locale = :fr
33
- end
34
- else
35
- I18n.locale = session[:locale] || :fr
36
- end
37
-
38
- # logger.debug "locale=[#{session[:locale]}]"
39
-
40
- if session[:locale] != I18n.locale
41
- session[:locale] = I18n.locale
42
- end
43
- end
44
12
  end
@@ -23,3 +23,29 @@ else
23
23
  puts "Railx V3.x.y, init_translations_ennder()"
24
24
  init_translations_ennder
25
25
  end
26
+
27
+
28
+ class ApplicationController
29
+ # Instance methods here
30
+ def set_locale
31
+ if (params[:locale] and params[:locale].match /^(en|fr)$/)
32
+ I18n.locale = params[:locale]
33
+ elsif session[:locale].nil?
34
+ _http_lang = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
35
+ if _http_lang.match /^(en|fr)$/
36
+ I18n.locale = _http_lang
37
+ else
38
+ I18n.locale = :fr
39
+ end
40
+ else
41
+ I18n.locale = session[:locale] || :fr
42
+ end
43
+
44
+ # logger.debug "locale=[#{session[:locale]}]"
45
+
46
+ if session[:locale] != I18n.locale
47
+ session[:locale] = I18n.locale
48
+ end
49
+ end
50
+ end
51
+
data/version.txt CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translations_ennder
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ennder