Merge remote-tracking branch 'origin/locale' into locale

This commit is contained in:
pixeldesu 2015-05-27 03:54:04 +02:00
commit 75a7b393b9
4 changed files with 10 additions and 6 deletions

View File

@ -14,6 +14,8 @@ class ApplicationController < ActionController::Base
I18n.locale = current_user.locale I18n.locale = current_user.locale
elsif not cookies[:hl].nil? elsif not cookies[:hl].nil?
I18n.locale = cookies[:hl] I18n.locale = cookies[:hl]
elsif not http_accept_language.user_preferred_languages.length > 0
I18n.locale = http_accept_language.compatible_language_from(I18n.available_locales) or "en"
end end
else else
I18n.locale = params[:hl] I18n.locale = params[:hl]

View File

@ -43,10 +43,10 @@ module ApplicationHelper
content_tag(:span, body, {title: tooltip_content, "data-toggle" => "tooltip", "data-placement" => placement} ) content_tag(:span, body, {title: tooltip_content, "data-toggle" => "tooltip", "data-placement" => placement} )
end end
def time_tooltip(question, placement = "bottom") def time_tooltip(subject, placement = "bottom")
t = tooltip time_ago_in_words(question.created_at), localize(question.created_at), placement t = tooltip time_ago_in_words(subject.created_at), localize(subject.created_at), placement
unless question.user.nil? or question.author_is_anonymous unless subject.user.nil? or (subject.respond_to?(:author_is_anonymous) and subject.author_is_anonymous)
t = content_tag(:a, t, {href: show_user_question_path(question.user.screen_name, question.id)}) t = content_tag(:a, t, {href: show_user_question_path(subject.user.screen_name, subject.id)})
end end
t t
end end

View File

@ -54,14 +54,14 @@
%h6.media-heading.answerbox--answer-user %h6.media-heading.answerbox--answer-user
= raw t('views.answerbox.answered', hide: hidespan(t('views.answerbox.hide'), "xs"), user: user_screen_name(a.user)) = raw t('views.answerbox.answered', hide: hidespan(t('views.answerbox.hide'), "xs"), user: user_screen_name(a.user))
.answerbox--answer-date .answerbox--answer-date
= link_to((raw t('views.answerbox.time', time: tooltip(time_ago_in_words(a.created_at), a.created_at, "bottom"))), show_user_answer_path(a.user.screen_name, a.id)) = link_to(raw(t('views.answerbox.time', time: time_tooltip(a))))
.col-md-6.col-sm-8.col-xs-6.text-right .col-md-6.col-sm-8.col-xs-6.text-right
= render 'shared/answerbox_buttons', a: a = render 'shared/answerbox_buttons', a: a
- else - else
.row .row
.col-md-6.col-sm-4.col-xs-6.text-left.text-muted .col-md-6.col-sm-4.col-xs-6.text-left.text-muted
%i.fa.fa-clock-o %i.fa.fa-clock-o
= link_to((raw t('views.answerbox.time', time: tooltip(time_ago_in_words(a.created_at), a.created_at, "bottom"))), show_user_answer_path(a.user.screen_name, a.id)) = link_to(raw(t('views.answerbox.time', time: time_tooltip(a))))
.col-md-6.col-sm-8.col-xs-6.text-right .col-md-6.col-sm-8.col-xs-6.text-right
= render 'shared/answerbox_buttons', a: a = render 'shared/answerbox_buttons', a: a
.panel-footer{id: "ab-comments-section-#{a.id}", style: @display_all.nil? ? 'display: none' : nil } .panel-footer{id: "ab-comments-section-#{a.id}", style: @display_all.nil? ? 'display: none' : nil }

View File

@ -26,6 +26,8 @@ module Justask
config.i18n.default_locale = "en" config.i18n.default_locale = "en"
config.i18n.fallbacks = true config.i18n.fallbacks = true
config.i18n.enforce_available_locales = false
# DEPRECATION WARNING: Currently, Active Record suppresses errors raised # DEPRECATION WARNING: Currently, Active Record suppresses errors raised
# within `after_rollback`/`after_commit` callbacks and only print them to the logs. # within `after_rollback`/`after_commit` callbacks and only print them to the logs.