move i18n.loadLocale to the application template, remove localize controller & helper, renamed localize to get_javascript_strings_for and added it to the application helper
This commit is contained in:
parent
ee218ecd44
commit
0831ad6e40
5 changed files with 11 additions and 26 deletions
|
|
@ -49,4 +49,10 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
def get_javascript_strings_for language
|
||||
yml_path = File.join(Rails.root, "config/locales/diaspora/", "#{language}.yml")
|
||||
yaml = YAML::load IO.read(yml_path)
|
||||
|
||||
yaml[language]["javascripts"]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
class LocalizeController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
|
||||
include LocalizeHelper
|
||||
|
||||
def show
|
||||
if current_user
|
||||
render :json => localize current_user.language
|
||||
else
|
||||
redirect_to aspects_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
module LocalizeHelper
|
||||
def localize language
|
||||
yml_path = File.join(Rails.root, "config/locales/diaspora/", "#{language}.yml")
|
||||
yaml = YAML::load IO.read(yml_path)
|
||||
|
||||
yaml[language]["javascripts"]
|
||||
end
|
||||
end
|
||||
|
|
@ -5,9 +5,7 @@
|
|||
|
||||
- content_for :head do
|
||||
= include_javascripts :home
|
||||
:javascript
|
||||
Diaspora.widgets.i18n.loadLocale(#{localize(current_user.language).to_json}, "#{current_user.language}");
|
||||
|
||||
|
||||
.span-15.append-2
|
||||
= render 'aspects/no_contacts_message', :aspect => @aspect, :contact_count => @contacts.count
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,10 @@
|
|||
|
||||
- unless @landing_page
|
||||
= include_javascripts :main
|
||||
- if ["cz", "da", "de", "el", "es", "fr", "he", "hu", "id", "it", "ja", "ko", "nl", "pl", "pt", "ro", "ru", "sv", "zh-CN"].include?(I18n.locale.to_s)
|
||||
= javascript_include_tag "vendor/timeago_locale/jquery.timeago.#{I18n.locale.to_s}.js"
|
||||
-if current_user
|
||||
:javascript
|
||||
Diaspora.widgets.i18n.loadLocale(#{get_javascript_strings_for(current_user.language).to_json}, "#{current_user.language}");
|
||||
|
||||
|
||||
- if current_user
|
||||
= include_javascripts :flash_socket #unless modern_browser?
|
||||
|
|
|
|||
Loading…
Reference in a new issue