diff --git a/Gemfile b/Gemfile index 06b3e3f..2b41610 100644 --- a/Gemfile +++ b/Gemfile @@ -79,6 +79,7 @@ # ------------------------------------------------ # INTERNATIONALIZATION gem "i18n-js", ">= 3.0.0.rc11" #damodar added TODO: explain +gem 'gettext_i18n_rails', '~> 1.8' # ------------------------------------------------ # API diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 6564cb5..a02811c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -17,29 +17,21 @@ redirect_to root_url, alert: I18n.t('unauthorized') end - before_filter :set_locale + before_filter :set_gettext_locale after_filter :store_location - def set_locale - # parameter from url takes precedence - # check if locale is defined - if params[:locale] # and I18n.available_locales.include? params[:locale] # throw an error if not available - # if locales data is present in the parameter from url use it - I18n.locale = params[:locale] - + def set_gettext_locale + if params[:locale] and FastGettext.default_available_locales.include?(params[:locale]) + FastGettext.locale = params[:locale] elsif user_signed_in? and !current_user[:language_id].nil? - I18n.locale = Language.find_by_id(current_user[:language_id]).abbreviation - # if user has set preferred language use it - + FastGettext.locale = Language.find_by_id(current_user[:language_id]).abbreviation #Relies on successful db call elsif user_signed_in? and current_user.org.present? and !current_user.org[:language_id].nil? - I18n.locale = Language.find_by_id(current_user.org[:language_id]).abbreviation - # use user's organization language, keep in mine the "OTHER ORG" edge case which should use default language - + FastGettext.locale = Language.find_by_id(current_user.org[:language_id]).abbreviation #Relies on successful db call else - # just use the default language, line can be commented out, included just for clarity - I18n.locale = I18n.default_locale + FastGettext.locale = FastGettext.default_locale end + puts 'FastGettext.locale = '+FastGettext.locale end # Added setting for passing local params across pages diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 73851a3..0d8de1a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -23,4 +23,10 @@ def hash_to_js_json_variable(obj_name, hash) "".html_safe end + + # Determines whether or not the URL path passed matches with the full path (including params) of the last URL requested. + # see http://api.rubyonrails.org/classes/ActionDispatch/Request.html#method-i-fullpath for details + def isActivePage(path) + return request.fullpath() == path + end end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 4c03d50..40441b0 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -2,13 +2,10 @@
-

<%= raw t('welcome_title')%>

- <%= raw t('welcome_text', - application_name: Rails.configuration.branding[:application][:name], - organisation_name: Rails.configuration.branding[:organisation][:name])%> - +

<%= _('Welcome.')%>

+ <%= raw _('

%{application_name} has been jointly developed by the %{organisation_name} to help you write data management plans.

') % {:application_name => Rails.configuration.branding[:application][:name], :organisation_name => Rails.configuration.branding[:organisation][:name]} %>
-

<%= t('screencast_text', application_name: Rails.configuration.branding[:application][:name]) %>

+

<%= _('Screencast on how to use %{application_name}') % {:application_name => Rails.configuration.branding[:application][:name]} %>

@@ -30,7 +27,7 @@
- <%= t('helpers.sign_in')%> + <%= _('Sign in')%>
@@ -41,9 +38,9 @@
- <%= t('helpers.sign_up') %> + <%= _('Sign up') %>

- <%= t('helpers.sign_up_text', application_name: Rails.configuration.branding[:application][:name])%> + <%= _('New to %{application_name}? Sign up today.') % {:application_name => Rails.configuration.branding[:application][:name]} %>

diff --git a/app/views/layouts/_navigation.html.erb b/app/views/layouts/_navigation.html.erb index dca92ca..15d8c1d 100644 --- a/app/views/layouts/_navigation.html.erb +++ b/app/views/layouts/_navigation.html.erb @@ -1,38 +1,21 @@ - - - -<% current_path = request.path%> -<% namespace = controller_path.split("/").first %> +