From 0831ad6e408602dd0ca6bc3c01e3df27209ef3bf Mon Sep 17 00:00:00 2001 From: Dan Hansen <mokker1234@gmail.com> Date: Tue, 25 Jan 2011 22:31:52 -0600 Subject: [PATCH] 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 --- app/controllers/application_controller.rb | 6 ++++++ app/controllers/localize_controller.rb | 13 ------------- app/helpers/localize_helper.rb | 8 -------- app/views/aspects/index.html.haml | 4 +--- app/views/layouts/application.html.haml | 6 ++++-- 5 files changed, 11 insertions(+), 26 deletions(-) delete mode 100644 app/controllers/localize_controller.rb delete mode 100644 app/helpers/localize_helper.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0b644dd59f..9b1f86ab77 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/controllers/localize_controller.rb b/app/controllers/localize_controller.rb deleted file mode 100644 index 29f07299fc..0000000000 --- a/app/controllers/localize_controller.rb +++ /dev/null @@ -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 \ No newline at end of file diff --git a/app/helpers/localize_helper.rb b/app/helpers/localize_helper.rb deleted file mode 100644 index 174c359eae..0000000000 --- a/app/helpers/localize_helper.rb +++ /dev/null @@ -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 \ No newline at end of file diff --git a/app/views/aspects/index.html.haml b/app/views/aspects/index.html.haml index a68daec9ed..723d4f4f7e 100644 --- a/app/views/aspects/index.html.haml +++ b/app/views/aspects/index.html.haml @@ -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 diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 44abd7cdfb..0a4a141c8e 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -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? -- GitLab