Skip to content

Commit

Permalink
en i18n support
Browse files Browse the repository at this point in the history
  • Loading branch information
windy committed Apr 6, 2015
1 parent edd1921 commit 15cb174
Show file tree
Hide file tree
Showing 26 changed files with 226 additions and 116 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/angularjs/admin_posts.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

$scope.changeToPreview = ->
$scope.body_active = false
$scope.previewHTML = '加载中...'
$scope.previewHTML = 'Loading...'
$http.post '/admin/posts/preview', { content: $scope.content }
.success (res)->
$scope.previewHTML = res
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/angularjs/admin_sessions.js.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@app.controller 'AdminSessionsController', [ '$scope', '$http', '$timeout', '$cookies', ($scope, $http, $timeout, $cookies)->
url = '/admin/sessions'

$scope.login = ->
$http
url: url
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/angularjs/comments.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
$scope.publish_fail_msg = res.message
.error (data, status)->
$scope.publish_success = false
$scope.publish_fail_msg = '网络错误, 请重试, 错误码为: ' + status
$scope.publish_fail_msg = 'Network Error, Retry for a moment, Status Code: ' + status
.finally ->
$scope.submitting = false
$scope.timeout = $timeout ->
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
border-top: 1px solid #dddddd;
padding: 1rem 0 2rem;
text-align: right;
color: #666;
.link {
margin-right: 1rem;
}
Expand Down
6 changes: 3 additions & 3 deletions app/assets/stylesheets/foundation_and_overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -950,9 +950,9 @@ $base-font-size: 100%;
// $include-html-tabs-classes: $include-html-classes;

// $tabs-navigation-padding: rem-calc(16);
// $tabs-navigation-bg-color: #efefef ;
// $tabs-navigation-active-bg-color: #fff;
// $tabs-navigation-hover-bg-color: scale-color($tabs-navigation-bg-color, $lightness: -6%);
$tabs-navigation-bg-color: #fff;
$tabs-navigation-active-bg-color: #eee;
$tabs-navigation-hover-bg-color: scale-color($tabs-navigation-bg-color, $lightness: -3%);
// $tabs-navigation-font-color: #222;
// $tabs-navigation-font-size: rem-calc(16);
// $tabs-navigation-font-family: $body-font-family;
Expand Down
2 changes: 1 addition & 1 deletion app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Comment
belongs_to :post

validates :name, presence: true
validates :email, presence: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, message: '地址无效' }
validates :email, presence: true, format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, message: I18n.t('comment_attributes.email') }
validates :content, presence: true
validates_presence_of :post_id

Expand Down
20 changes: 10 additions & 10 deletions app/views/admin/comments/index.html.slim
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
.row.admin-posts-field
.small-12.columns
h3.blog-title 评论管理
h3.blog-title #{t('admin.comments')}
h4.blog-title
= link_to @post.title, blog_path(@post), target: '_blank'
table width="100%"
thead
tr
th 名字
th 邮箱
th 内容
th 时间
th 操作
th #{t('admin.comments_head.name')}
th #{t('admin.comments_head.email')}
th #{t('admin.comments_head.content')}
th #{t('admin.comments_head.created_at')}
th #{t('admin.comments_head.operation')}
tbody
- @comments.each do |comment|
tr
td #{comment.name}
td
td
= mail_to comment.email
td
td
p.pre #{comment.content}
td
= format_time(comment.created_at)

td
= link_to '回复', blog_path(@post), target: '_blank', class: 'edit-post-link'
= link_to '删除', admin_post_comment_path(@post, comment), method: 'DELETE', 'data-confirm'=> '确认删除?'
= link_to t('admin.comments_head.reply'), blog_path(@post), target: '_blank', class: 'edit-post-link'
= link_to t('admin.comments_head.destroy'), admin_post_comment_path(@post, comment), method: 'DELETE', 'data-confirm'=> '确认删除?'
15 changes: 7 additions & 8 deletions app/views/admin/dashboard/index.html.slim
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
.row
.small-12.columns
h2.dash-title 统计信息
h2.dash-title #{t('admin.dashboard.head')}
hr
table width="100%"
thead
tr
th 条目
th 数据
th #{t('admin.dashboard.info')}
th #{t('admin.dashboard.data')}
tbody
tr
td 总博客数
td #{t('admin.dashboard.posts_count')}
td #{@posts_count}
tr
td 总评论数
td #{t('admin.dashboard.comments_count')}
td #{@comments_count}
tr
td 总浏览量
td #{t('admin.dashboard.visited_count')}
td #{@visited_count}
tr
td 总订阅量
td #{t('admin.dashboard.subscribes_count')}
td #{@subscribes_count}

18 changes: 9 additions & 9 deletions app/views/admin/posts/_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
= simple_form_for(@post, url: url, html: {novalidate: '' }) do |f|
.row
.large-6.columns
= f.input :title, label: '标题', "ng-model"=>"title", input_html: { name: 'title' }
= f.input :title, label: t('admin.posts_attributes.title'), "ng-model"=>"title", input_html: { name: 'title' }
.row
.small-6.large-3.columns
= f.input :type, :as=>:select, :collection=> [ Post::TECH, Post::LIFE, Post::CREATOR ], label: '类别', "ng-model"=>"type", input_html: { name: 'type' }
= f.input :type, :as=>:select, :collection=> [ Post::TECH, Post::LIFE, Post::CREATOR ], label: t('admin.posts_attributes.type'), "ng-model"=>"type", input_html: { name: 'type' }
.row
.small-12.large-6.columns
= label_tag :labels, '标签'
= label_tag :labels, t('admin.posts_attributes.labels')
= text_field_tag :labels, @post.labels_content(true), "ng-model"=>"labels", "ng-initial" => ''

.row
.small-12.columns
p
| 已有标签:
| #{t('admin.posts_attributes.already_labels')}
span
- Label.all.each do |label|
a.tag href="#" ng-click="addTag($event)" #{label.name}

/ tabs and upload file field
dl.tabs
dd ng-class="{ active: body_active }"
a href="" ng-click="changeToBody()" 正文
a href="" ng-click="changeToBody()" #{t('admin.posts_attributes.content')}
dd ng-class="{ active: !body_active }"
a href="#" ng-click="changeToPreview()" 预览
= link_to '上传图片', "#", :id=>'upload_photo'
a href="#" ng-click="changeToPreview()" #{t('admin.posts_attributes.preview')}
= link_to t('admin.posts_attributes.upload_photo'), "#", :id=>'upload_photo'
input[type="file" style="display: none;"]

.content-field ng-show="body_active" ng-model= 'content'
Expand All @@ -35,4 +35,4 @@

.row
.small-12.large-6.columns.posts-button
button 提交
button #{t('admin.posts_attributes.submit')}
17 changes: 8 additions & 9 deletions app/views/admin/posts/index.html.slim
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
.row.admin-posts-field
.small-12.columns
h3.blog-title 博客管理
h3.blog-title #{t('admin.posts') }
table width="100%"
thead
tr
th 标题
th 概要
th 操作
th #{t('admin.posts_head.title')}
th #{t('admin.posts_head.summary')}
th #{t('admin.posts_head.operation')}
tbody
- @posts.each do |post|
tr
td
td
= link_to post.title, blog_path(post)
td.admin-post-summary-field
i.fi-calendar
Expand All @@ -24,7 +24,6 @@
i.fi-heart
span #{ post.liked_count }
td
= link_to '评论', admin_post_comments_path(post.id), class: 'edit-post-link'
= link_to '编辑', edit_admin_post_path(post), class: 'edit-post-link'
= link_to '删除', admin_post_path(post), method: 'DELETE', 'data-confirm' => '确认删除?'

= link_to t('comment'), admin_post_comments_path(post.id), class: 'edit-post-link'
= link_to t('edit'), edit_admin_post_path(post), class: 'edit-post-link'
= link_to t('destroy'), admin_post_path(post), method: 'DELETE', 'data-confirm' => '确认删除?'
2 changes: 1 addition & 1 deletion app/views/admin/posts/new.html.slim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.row
.small-12.columns
.admin-posts-field ng-controller="AdminPostsController"
h3.blog-title 新建博客
h3.blog-title #{t('admin.new_post')}
= render 'form'
4 changes: 2 additions & 2 deletions app/views/archives/index.html.slim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- content_for(:title) do
| #{@type ? @type : '时间线'}
| #{@type ? @type : t('title.timeline')}
.row ng-controller="ArchivesController" ng-cloak=""
.small-12.large-9.large-centered.columns
ul.archives-field ng-model="type" ng-init=" type= '#{@type}' "
Expand All @@ -23,7 +23,7 @@
span
|{{ post.liked_count }}
.no-more-field
p ng-show="no_more_flag" 没有更多内容
p ng-show="no_more_flag" #{t('nocontent')}

.load-more
button.small ng-click="load()" ng-show="!loading_flag" Load More
Expand Down
14 changes: 7 additions & 7 deletions app/views/blogs/_comment.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
form novalidate='' name='form'
.row
.small-12.large-12.columns
= text_area_tag(:content, nil, placeholder: '发表你的看法', 'ng-model'=> 'content', 'ng-required'=> true)
= text_area_tag(:content, nil, placeholder: t('comment_placeholder.content'), 'ng-model'=> 'content', 'ng-required'=> true)
.row
.small-12.large-6.columns
= text_field_tag(:name, nil, placeholder: '你的名字', 'ng-model'=> 'name', 'ng-required'=> 'true')
= text_field_tag(:email, nil, placeholder: '你的邮箱', 'ng-model'=> 'email', 'ng-pattern'=>"/^.+@.+$/", 'ng-required'=>"true")
button.comment-submit ng-click="submit()" ng-disabled="form.$invalid || submitting" {{ submitting && '发表中' || '发表' }}
p.comment-success ng-show="publish_success" 发布成功
p.comment-fail ng-show="publish_success == false" 发布失败: {{ publish_fail_msg }}
= text_field_tag(:name, nil, placeholder: t('comment_placeholder.name'), 'ng-model'=> 'name', 'ng-required'=> 'true')
= text_field_tag(:email, nil, placeholder: t('comment_placeholder.email'), 'ng-model'=> 'email', 'ng-pattern'=>"/^.+@.+$/", 'ng-required'=>"true")
button.comment-submit ng-click="submit()" ng-disabled="form.$invalid || submitting" {{ submitting && "#{t('comment_placeholder.submitting')}" || "#{t('comment_placeholder.submit')}" }}
p.comment-success ng-show="publish_success" #{t('comment_placeholder.publish_success')}
p.comment-fail ng-show="publish_success == false" #{t('comment_placeholder.publish_fail')}: {{ publish_fail_msg }}
.comment-diag
.comment-wrapper ng-repeat=" comment in comments "
p.name
|{{ comment.name + " • " }}
span.created-at
|{{ comment.created_at }}
p.comment-content
|{{ comment.content }}
| {{ comment.content }}
2 changes: 1 addition & 1 deletion app/views/blogs/_qrcode.html.slim
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.qrcode-image
= image_tag( qrcodes_path(str: str) )
p 使用手机继续阅读 or 帮我分享至微信朋友圈
p #{t('qrcodetips')}
32 changes: 14 additions & 18 deletions app/views/blogs/index.html.slim
Original file line number Diff line number Diff line change
@@ -1,50 +1,46 @@
- if ENV['INTRODUCE'].present?
- if ENV['INTRODUCE'].present?
- content_for(:meta) do
meta name="description" content="#{ENV['INTRODUCE'].dup.force_encoding('UTF-8')}"
- content_for(:title) do
| 首页
| #{t('title.home')}
.row
.small-12.large-8.columns
- unless @newest
h2.blog-title 这里还没有博客
p
| 这里还没有博客, 请访问
= link_to '管理页面', new_admin_post_path
| 来创建第一篇博客
= render 'common/no_blog_here'
- else
= render partial: 'post_head', locals: { post: @newest }
.content.markdown
== @newest.sub_content

= link_to "阅读全文 >>", blog_path(@newest), class: 'read-more'
p.published-at 发表于 #{format_date(@newest.created_at)}
= link_to t('home.read'), blog_path(@newest), class: 'read-more'
p.published-at #{t('home.created_at')} #{format_date(@newest.created_at)}

h4.recent-title RECENT
ul.recent-content
- @recent.each do |re|
li = link_to "#{re.title}",blog_path(re)

.large-3.columns.large-offset-1.self-introduce.self-introduce-index ng-controller='AboutController'
/*请到 common 调整个人设置*/
.large-3.columns.large-offset-1.self-introduce.self-introduce-index
/*Adjust it in common/welcome*/
= render 'common/welcome'
h4 SUBSCRIBE
.row.ng-cloak
h4 #{t('subscribes.title')}
.row.ng-cloak ng-controller='AboutController'
.small-12.medium-6.large-12.columns
ul.subscribe-ul
- if ENV['MAIL_SERVER'].present?
li
= link_to '邮件订阅 ', '', "ng-click"=>"click('email')"
= link_to t('subscribes.email'), '', "ng-click"=>"click('email')"
.email-subscribe ng-show="type == 'email'"
= text_field_tag 'email', nil, placeholder: '[email protected]', 'ng-model'=>'email'
button.small ng-click="subscribe()" ng-disabled="! email_validate()" 订阅
span.subscribe-success ng-show="subscribe_success" 订阅成功
button.small ng-click="subscribe()" ng-disabled="! email_validate()" #{t('subscribes.submit')}
span.subscribe-success ng-show="subscribe_success" #{t('subscribes.submit_success')}
span.subscribe-fail ng-show="subscribe_success == false" {{subscribe_fail_msg}}
li
= link_to '微信扫一扫', '', "ng-click"=>"click('weixin')"
= link_to t('subscribes.wechat'), '', "ng-click"=>"click('weixin')"
.weixin-subscribe ng-show="type == 'weixin'"
= render partial: "qrcode", locals: { str: root_url }
li
= link_to 'RSS订阅', '', "ng-click"=>"click('rss')"
= link_to t('subscribes.rss'), '', "ng-click"=>"click('rss')"
.rss-subscribe ng-show="type == 'rss'"
= link_to rss_blogs_path do
- image_tag('rss.png')
5 changes: 5 additions & 0 deletions app/views/common/_no_blog_here.en.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
h2.blog-title #{t('home.no_blog_here')}
p
| No post here, please visit
= link_to ' Manage Post ', new_admin_post_path
| to create the first post.
5 changes: 5 additions & 0 deletions app/views/common/_no_blog_here.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
h2.blog-title #{t('home.no_blog_here')}
p
| 这里还没有博客, 请访问
= link_to '管理页面', new_admin_post_path
| 来创建第一篇博客
16 changes: 16 additions & 0 deletions app/views/common/_welcome.en.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* adjust stylesheet: .self-introduce-index */
h4 WELCOME
p I'm Li Yafei, WinDy is my English name.

h4 ABOUT
ul.aboutme-index
li
span Industry:
span Web Development, Startups, Life
li
span Location:
span Nan Shan District, ShenZhen, China
li
span More:
span
= link_to 'About Me', about_path
6 changes: 3 additions & 3 deletions app/views/common/_welcome.html.slim
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* 样式调整请找 stylesheet: .self-introduce-index */
h4 WELCOME
h4 欢迎
p 我是李亚飞, WinDy 是我的网名.

h4 ABOUTME
h4 关于我
ul.aboutme-index
li
span 领域:
Expand All @@ -11,6 +11,6 @@ ul.aboutme-index
span 位置:
span 中国 - 深圳 - 南山
li
span 更多:
span 更多:
span
= link_to '关于我', about_path
3 changes: 1 addition & 2 deletions app/views/home/index.html.slim
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
- content_for(:title) do
| 关于我
| #{t('title.about')}
- content_for(:main) do
/! 导航
.about-page ng-app='app' ng-controller='AboutScrollController'
.top-bar-wrapper.contain-to-grid.fixed ng-class="{ active: ! is_top() }"
.row
Expand Down
7 changes: 6 additions & 1 deletion app/views/layouts/_footer.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
span.link yafeilee.me
span.time © 2012 - 2015
.license
span
| Designed by
span
= link_to 'WinDy', about_path, target: '_blank'
.license
| Built with
span
= link_to 'wblog', 'https://github.com/windy/wblog', target: '_blank'
Loading

0 comments on commit 15cb174

Please sign in to comment.