Add rails-i18n, more locales

This commit is contained in:
Rei
2014-02-23 22:06:17 +08:00
parent b14455fb81
commit b6d97a5ae6
12 changed files with 100 additions and 24 deletions

View File

@@ -71,6 +71,9 @@ gem 'mini_magick', '~> 3.7.0'
# User locale detect
gem 'http_accept_language', '~> 2.0.1'
# i18n
gem 'rails-i18n', '~> 4.0.1'
group :development do
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/jonleighton/spring
gem 'spring'

View File

@@ -198,6 +198,9 @@ GEM
rack
rack-test (0.6.2)
rack (>= 1.0)
rails-i18n (4.0.1)
i18n (~> 0.6)
rails (~> 4.0)
rake (10.1.1)
rb-fsevent (0.9.4)
rb-inotify (0.9.3)
@@ -263,6 +266,7 @@ DEPENDENCIES
pg
rack-livereload
rails!
rails-i18n (~> 4.0.1)
redcarpet (~> 3.0.0)
rouge (~> 1.3.1)
sass-rails!

View File

@@ -3,10 +3,10 @@
ul.nav.nav-pills.nav-stacked
li class=('active' if controller_name == 'accounts')
a href=settings_account_path
| Account
= t '.account'
li class=('active' if controller_name == 'passwords')
a href=settings_password_path
| Password
= t '.password'
li class=('active' if controller_name == 'profiles')
a href=settings_profile_path
| Profile
= t '.profile'

View File

@@ -3,7 +3,7 @@
.panel.panel-campo
.panel-heading
h3.panel-title
| Account
= t '.account'
.panel-body
= form_for @user, url: settings_account_path, html: { class: 'form-horizontal user-form' } do |f|
= render 'share/flash_messages'
@@ -19,14 +19,14 @@
.form-group
= f.label :locale, class: 'control-label col-sm-3'
.col-sm-6
= f.select :locale, I18n.available_locales.map { |locale| [t("locale.#{locale}"), locale] }, {}, class: 'form-control'
= f.select :locale, I18n.available_locales.map { |locale| [t("locales.#{locale}"), locale] }, {}, class: 'form-control'
.form-group
= label_tag :current_password, :current_password, class: 'control-label col-sm-3'
= label_tag :current_password, t('.current_password'), class: 'control-label col-sm-3'
.col-sm-6
= password_field_tag :current_password, nil, class: 'form-control', autocomplete: 'off'
.form-group
.col-sm-6.col-sm-push-3
= f.submit 'Save changes', class: 'btn btn-primary'
= f.submit t('.save_changes'), class: 'btn btn-primary'
.col-md-3
= render 'settings/sidebar'

View File

@@ -3,13 +3,13 @@
.panel.panel-campo
.panel-heading
h3.panel-title
| Password
= t '.password'
.panel-body
= form_for @user, url: settings_password_path, html: { class: 'form-horizontal password-form' } do |f|
= render 'share/flash_messages'
= render 'share/form_error_messages', form: f
.form-group
= label_tag :current_password, :current_password, class: 'control-label col-sm-3'
= label_tag :current_password, t('.current_password'), class: 'control-label col-sm-3'
.col-sm-6
= text_field_tag :current_password, nil, class: 'form-control'
.form-group
@@ -22,7 +22,7 @@
= f.text_field :password_confirmation, class: 'form-control'
.form-group
.col-sm-6.col-sm-push-3
= f.submit 'Save changes', class: 'btn btn-primary'
= f.submit t('.save_changes'), class: 'btn btn-primary'
.col-md-3
= render 'settings/sidebar'

View File

@@ -3,13 +3,13 @@
.panel.panel-campo
.panel-heading
h3.panel-title
| Profile
= t '.profile'
.panel-body
= form_for @user, url: settings_profile_path, html: { multipart: true, class: 'form-horizontal user-form' } do |f|
= render 'share/flash_messages'
= render 'share/form_error_messages', form: f
.form-group
label.control-label.col-sm-3 Avatar
= f.label :avatar, class: 'control-label col-sm-3'
.col-sm-6.user-image-uploader
.image
img.img-rounded alt="avatar" src=current_user.avatar.bigger.url
@@ -30,7 +30,7 @@
= f.text_area :bio, class: 'form-control'
.form-group
.col-sm-6.col-sm-push-3
= f.submit 'Save changes', class: 'btn btn-primary'
= f.submit t('.save_changes'), class: 'btn btn-primary'
.col-md-3
= render 'settings/sidebar'

View File

@@ -13,6 +13,4 @@ a.list-group-item.topic href=topic_path(topic)
= ' · '
= time_ago_in_words topic.created_at
= ' · '
= topic.comments_count
'
| comments
= t '.comments_count', count: topic.comments_count

View File

@@ -19,7 +19,7 @@
.form-group
= f.label :password, class: 'control-label'
= f.password_field :password, placeholder: 'Create a password', tabindex: 4, class: 'form-control'
= f.submit t('create_account'), class: 'btn btn-success', tabindex: 5
= f.submit t('.create_account'), class: 'btn btn-success', tabindex: 5
javascript:
$('#new-user-form').validate({

View File

@@ -19,7 +19,8 @@ module Campo
# 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
config.i18n.available_locales = [:en, 'zh-CN']
config.generators do |g|
g.assets false

View File

@@ -1,7 +1,7 @@
base_locale: en
locales: [zh-CN]
search:
include:
- '*.rb'
- '*.slim'
ignore_unused:
- activerecord.attributes.*

View File

@@ -1,6 +1,16 @@
---
en:
create_account: Create account
activerecord:
attributes:
user:
avatar: Avatar
bio: Bio
email: Email
locale: Locale
name: Name
password: Password
password_confirmation: Password confirmation
username: Username
layouts:
application:
likes: Likes
@@ -9,6 +19,9 @@ en:
sign_in: Sign in
sign_up: Sign up
topics: Topics
locales:
en: English
zh-CN: Chinese(Simplified)
markdown:
area:
attach_images_by: Attach images by
@@ -25,6 +38,25 @@ en:
sessions:
new:
sign_in: Sign in
settings:
accounts:
show:
account: Account
current_password: Current password
save_changes: Save changes
passwords:
show:
current_password: Current password
password: Password
save_changes: Save changes
profiles:
show:
profile: Profile
save_changes: Save changes
sidebar:
account: Account
password: Password
profile: Profile
subscriptions:
subscription:
ignoring: Ignoring
@@ -68,6 +100,8 @@ en:
your_account_had_been_locked: Your account had been locked
sidebar_search:
search: Search
topic:
comments_count: "%{count} comments"
users:
comments:
index:
@@ -78,6 +112,7 @@ en:
likes: Likes
no_like_yet: No like yet
new:
create_account: Create account
sign_up: Sign up
profile:
edit_profile: Edit profile

View File

@@ -1,6 +1,16 @@
---
zh-CN:
create_account: "创建帐号"
activerecord:
attributes:
user:
avatar: '头像'
bio: '简介'
email: Email
locale: "语言"
name: "全名"
password: "密码"
password_confirmation: "密码确认"
username: "用户名"
layouts:
application:
likes: "收藏"
@@ -9,6 +19,9 @@ zh-CN:
sign_in: "登录"
sign_up: "注册"
topics: "话题"
locales:
en: "英文"
zh-CN: "简体中文"
markdown:
area:
attach_images_by: "添加图片"
@@ -24,6 +37,25 @@ zh-CN:
sessions:
new:
sign_in: "登录"
settings:
accounts:
show:
account: "帐号"
current_password: "当前密码"
save_changes: "保存修改"
passwords:
show:
current_password: "当前密码"
password: "密码"
save_changes: "保存修改"
profiles:
show:
profile: "个人资料"
save_changes: "保存修改"
sidebar:
account: "帐号"
password: "密码"
profile: "个人资料"
subscriptions:
subscription:
ignoring: "忽略"
@@ -63,7 +95,9 @@ zh-CN:
topics: "话题"
your_account_had_been_locked: "你的帐号已被锁定"
sidebar_search:
search: '搜索'
search: "搜索"
topic:
comments_count: "%{count} 条评论"
users:
comments:
index:
@@ -74,6 +108,7 @@ zh-CN:
likes: "收藏"
no_like_yet: "还没有收藏"
new:
create_account: "创建帐号"
sign_up: "注册"
profile:
edit_profile: "编辑个人资料"