From 5c5dca0d497a761d7a29a5433cac838065982679 Mon Sep 17 00:00:00 2001 From: yafeilee Date: Wed, 8 Apr 2015 00:57:19 +0800 Subject: [PATCH] admin session page i18n --- app/controllers/admin/sessions_controller.rb | 8 ++++---- app/views/admin/sessions/new.html.slim | 12 ++++++------ config/locales/en.yml | 11 +++++++++++ config/locales/zh-CN.yml | 11 +++++++++++ 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/app/controllers/admin/sessions_controller.rb b/app/controllers/admin/sessions_controller.rb index c422e52..2d7914f 100644 --- a/app/controllers/admin/sessions_controller.rb +++ b/app/controllers/admin/sessions_controller.rb @@ -6,13 +6,13 @@ class Admin::SessionsController < ApplicationController def create if ENV['ADMIN_USER'].blank? - render :json=> { success: false, message: '系统未配置管理员账户, 无法登录' } + render :json=> { success: false, message: t('session.no_configuration') } elsif ENV['ADMIN_USER'] != params[:username] - render :json=> { success: false, message: '管理员账户错误' } + render :json=> { success: false, message: t('session.username_error') } elsif ENV['ADMIN_PASSWORD'] != params[:password] - render :json=> { success: false, message: '管理员密码错误' } + render :json=> { success: false, message: t('session.password_error') } else - flash[:notice] = '登录成功' + flash[:notice] = t('session.login_success') session[:login] = true render :json=> { success: true } end diff --git a/app/views/admin/sessions/new.html.slim b/app/views/admin/sessions/new.html.slim index 643d6d7..13221b0 100644 --- a/app/views/admin/sessions/new.html.slim +++ b/app/views/admin/sessions/new.html.slim @@ -1,16 +1,16 @@ .row ng-controller="AdminSessionsController" .small-12.large-8.columns - h3.blog-title 登录后台 + h3.blog-title #{t('session.title')} form ng-submit="login()" .row .small-12.large-8.columns - = label_tag 'username', '用户名' - = text_field_tag 'username', nil, placeholder: '管理员账号', "ng-model"=>"username" - = label_tag 'username', '密码' - = password_field_tag 'password', nil, placeholder: '管理员密码', "ng-model"=>"password" + = label_tag 'username', t('session.username') + = text_field_tag 'username', nil, placeholder: t('session.username_placeholder'), "ng-model"=>"username" + = label_tag 'username', t('session.password') + = password_field_tag 'password', nil, placeholder: t('session.password_placeholder'), "ng-model"=>"password" p .alert-box.warning ng-show=" error_msg " |{{ error_msg }} - button 登录 + button #{t('session.login_button')} diff --git a/config/locales/en.yml b/config/locales/en.yml index 6d69aef..5f46191 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -84,3 +84,14 @@ en: comments_count: 'Comments Count' visited_count: 'Visited Count' subscribes_count: 'Subscribes Count' + session: + title: 'Login dashboard' + username: 'Username' + username_placeholder: 'Admin username' + password: 'Password' + password_placeholder: 'Admin password' + login_button: 'Login now' + login_success: 'Login successfully' + no_configuration: 'There is no admin user, login failed' + username_error: 'Admin username error' + password_error: 'Admin password error' diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 5067fd3..9db853a 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -84,3 +84,14 @@ zh-CN: comments_count: '评论数' visited_count: '浏览数' subscribes_count: '订阅数' + session: + title: '登录后台' + username: '用户名' + username_placeholder: '管理员账号' + password: 'Password' + password_placeholder: '管理员密码' + login_button: '登录' + login_success: '登录成功' + no_configuration: '系统未配置管理员, 无法登录' + username_error: '用户名错误' + password_error: '密码错误'