Added pt-br Locale

This commit is contained in:
iobridge 2011-10-16 02:54:31 -04:00
parent 92b88e161a
commit 27490278a6
4 changed files with 20 additions and 8 deletions

View File

@ -7,12 +7,20 @@ class ApplicationController < ActionController::Base
before_filter :set_variables
# set up some variables across the entire application
def set_variables
# hard code locale as english
I18n.locale = 'en'
# sets timezone for current user, all DateTime outputs will be automatically formatted
Time.zone = current_user.time_zone if current_user
end
def set_variables
@locale ||= get_locale
I18n.locale = ALLOWED_LOCALES.include?(@locale) ? @locale : I18n.default_locale
# sets timezone for current user, all DateTime outputs will be automatically formatted
Time.zone = current_user.time_zone if current_user
end
# get the locale, but don't fail if header value doesn't exist
def get_locale
locale = get_header_value('HTTP_ACCEPT_LANGUAGE')
# only look for 'pt-br' as first 5 letters, can make more robust in future if other languages are needed
locale = locale[0..4].downcase if locale
return locale
end
private

View File

@ -28,7 +28,7 @@ module Thingspeak
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.i18n.default_locale = :en
# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)

View File

@ -1,3 +1,6 @@
# allow updates via HTTP GET by setting this to true;
# set to false to only allow updates via HTTP POST
GET_SUPPORT = true
GET_SUPPORT = true
# allow only these additional locales (use downcase, easier to parse)
ALLOWED_LOCALES = ['pt-br']

View File

@ -123,6 +123,7 @@ en:
email: "Email"
email_form_add: "Add Email"
featured_channels: "Featured Channels"
features: "Features"
field: "Field"
footer: "This is the footer message."
forgot: "Forgot your password?"