localyzed 0.0.1.9 → 0.0.2.0
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/README.rdoc +4 -9
- data/lib/localyzed/base.rb +0 -10
- data/lib/localyzed/controllers/action_controller_extension.rb +1 -1
- data/lib/localyzed/version.rb +1 -1
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -1,9 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
= expects user_interface in app to respond_to
|
6
|
-
|
7
|
-
signed_in? => boolean
|
8
|
-
current => a user instance which responds to
|
9
|
-
-> language => locale (symbol)
|
1
|
+
NB: expects controllers and views to implement the following methods
|
2
|
+
-> user_signed_in?
|
3
|
+
-> current_user
|
4
|
+
-> responding to language
|
data/lib/localyzed/base.rb
CHANGED
@@ -1,15 +1,5 @@
|
|
1
1
|
module Localyzed
|
2
2
|
|
3
|
-
mattr_accessor :user_interface
|
4
|
-
|
5
|
-
def self.configure(config)
|
6
|
-
@@user_interface = config[:user_interface] || nil
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.user_interface
|
10
|
-
@@user_interface.constantize
|
11
|
-
end
|
12
|
-
|
13
3
|
def self.localyze_routes(translations_file,options={})
|
14
4
|
ActionDispatch::Routing::Translator.translate_from_file(translations_file, options)
|
15
5
|
end
|
@@ -11,7 +11,7 @@ class ActionController::Base
|
|
11
11
|
|
12
12
|
# sets the locale by checking user data then request param then session data then retrieving accept language data
|
13
13
|
def set_locale
|
14
|
-
if
|
14
|
+
if user_signed_in? and cl = (current_user.respond_to?(:language) ? current_user.language : 'en') and I18n.available_locales.include?(cl)
|
15
15
|
locale = I18n.locale = cl
|
16
16
|
session[:locale] = locale
|
17
17
|
else
|
data/lib/localyzed/version.rb
CHANGED