translations_ennder 1.0.2 → 1.0.3

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/History.txt CHANGED
@@ -18,3 +18,6 @@
18
18
 
19
19
  == 1.0.2 / 2011-01-10
20
20
  * set_locale : extension Base:ActionController
21
+
22
+ == 1.0.3 / 2011-03-21
23
+ * set_locale : contrôle de sécurité
@@ -28,26 +28,39 @@ end
28
28
  module ActionController
29
29
  class Base
30
30
  # Instance methods here
31
+
31
32
  def set_locale
32
- if (params[:locale] and params[:locale].match /^(en|fr)$/)
33
- I18n.locale = params[:locale]
34
- elsif session[:locale].nil?
35
- _http_lang = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
36
- if _http_lang.match /^(en|fr)$/
37
- I18n.locale = _http_lang
33
+ _param_locale = params[:locale]
34
+ if (!_param_locale.blank?) and _param_locale.match /^(en|fr)$/)
35
+ #Vient du paramètre de requête
36
+ I18n.locale = _param_locale
37
+ elsif session[:locale].blank? and (! request.env['HTTP_ACCEPT_LANGUAGE'].blank?)
38
+ #Vient des entêtes de la requête
39
+ _http_lang_tab = request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/)
40
+ if (! _http_lang_tab.empty?) and (! _http_lang.first.blank? )
41
+ if _http_lang.first.match /^(en|fr)$/
42
+ I18n.locale = _http_lang.first
43
+ else
44
+ set_locale_session_or_fr
45
+ end
38
46
  else
39
- I18n.locale = :fr
47
+ set_locale_session_or_fr
40
48
  end
41
49
  else
42
- I18n.locale = session[:locale] || :fr
50
+ set_locale_session_or_fr
43
51
  end
44
52
 
45
- # logger.debug "locale=[#{session[:locale]}]"
53
+ # logger.debug "locale=[#{session[:locale]}]"
46
54
 
47
55
  if session[:locale] != I18n.locale
48
56
  session[:locale] = I18n.locale
49
57
  end
50
58
  end
59
+
60
+ def set_locale_session_or_fr
61
+ #Vient de la session, ou pas fourni
62
+ I18n.locale = session[:locale] || :fr
63
+ end
51
64
  end
52
65
  end
53
66
 
data/version.txt CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.0.3
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: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 2
10
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ennder
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-10 00:00:00 +01:00
18
+ date: 2011-03-21 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 27
29
+ hash: 21
30
30
  segments:
31
31
  - 3
32
+ - 6
32
33
  - 5
33
- - 4
34
- version: 3.5.4
34
+ version: 3.6.5
35
35
  type: :development
36
36
  version_requirements: *id001
37
37
  description: "Ce plugin apporte des traductions standard en fran\xC3\xA7ais et anglais.\n\
@@ -50,10 +50,8 @@ extra_rdoc_files:
50
50
  - lib/translations_ennder/locales/.directory
51
51
  - lib/translations_ennder/locales/en.yml
52
52
  - lib/translations_ennder/locales/fr.yml
53
- - version.txt
54
53
  files:
55
54
  - .bnsignore
56
- - .gitignore
57
55
  - History.txt
58
56
  - README.md
59
57
  - Rakefile
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- #Kde
2
- .directory
3
-
4
- #Bones
5
- pkg/translations_ennder-*/**/*
6
- pkg/translations_ennder-*/*
7
-
8
- pkg/translations_ennder-*.tgz