Skip to content

Commit

Permalink
Merge ca3e689 into 4a7d912
Browse files Browse the repository at this point in the history
  • Loading branch information
miurahr committed Apr 19, 2015
2 parents 4a7d912 + ca3e689 commit 14d3d8d
Show file tree
Hide file tree
Showing 27 changed files with 656 additions and 68 deletions.
47 changes: 47 additions & 0 deletions Localize.md
@@ -0,0 +1,47 @@
# How to localize

### Table of Contents

* [Overview](#overview)
* [Requirements](#requirements)
* [PO catalog handling](#makepo)

<hr>
# <a name="overview"></a> OverView

Localize of Kandan app is based on two framework.

One is for Ruby I18N/L10N. It utilize standard ruby simple internationalization framework.
Kandan also support external translation network service such as transifex.com.
Because these translation service requires GetText PO style file, we can convert YML
translation catalog to PO file, and vise versa.

Another is for Backbone.js I18N. We use i18next js library for its purpose.
We need further development for its area.

<hr>
# <a name="requirements"></a>Requirements
* Ruby 1.9

<hr>
# <a name="makepo"></a>PO catalog handling

At first we need to master POT template file.
```
script/yaml2po -P config/locale/admin/en.yml /config/locale/admin/admin.pot
```
Now you can upload POT file onto transifex.com or other translation
network service.

Creating language po file
```
script/yaml2po -l de -t config/locale/admin/en.yml config/admin/locale/de.yml config/locale/admin/de.po
```

Generate yml file from po file
To create a language's yaml from a given po file
```
script/po2yaml config/locale/admin/de.po config/locale/admin/de.yaml
```


9 changes: 9 additions & 0 deletions app/controllers/application_controller.rb
@@ -1,9 +1,18 @@
class ApplicationController < ActionController::Base
protect_from_forgery

before_filter :set_locale
before_filter :force_approved_account
before_filter :redirect_suspended_account

def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end

def default_url_options(options = {})
{ locale: I18n.locale }.merge options
end

def force_approved_account
# We will redirect to the approval page if a user is signed in, is not an admin and is marked as waiting for approval
redirect = user_signed_in? && !current_user.is_admin? && current_user.registration_status.waiting_approval?
Expand Down
14 changes: 7 additions & 7 deletions app/views/admin/admin/index.html.erb
Expand Up @@ -8,19 +8,19 @@

<div class="admin">
<div class="site-settings">
<h3>Site settings</h3>
<h3><%= t('admin.site_settings') %></h3>
<%= form_for @settings, :url => admin_update_path, :method => :post do |f| %>
<%= f.label :max_rooms do %>
Max number of rooms <%= f.number_field :max_rooms, :class => "input-mini pull-right" %>
<%= t('admin.max_number_of_rooms') %><%= f.number_field :max_rooms, :class => "input-mini pull-right" %>
<% end %>
<%= f.label :disable_conn_disconn_activity do %>
<%= f.check_box :disable_conn_disconn_activity, :class => "switch" %> disable connect/disconnect activity
<%= f.check_box :disable_conn_disconn_activity, :class => "switch" %><%= t('admin.disable_connect') %>
<span></span>
<% end %>
<%= f.label :public_site do %>
<%= f.check_box :public_site, :class => "switch" %> Public site
<%= f.check_box :public_site, :class => "switch" %> <%= t('admin.public_site') %>
<span></span>
<% end %>
<p>
Expand All @@ -29,17 +29,17 @@
<% end %>
</div>
<div class="waiting-for-approval-users">
<h3>Users waiting for approval</h3>
<h3><%= t('admin.users_waiting_approval') %></h3>
<ul class="users">
<%= render(:collection => @waiting_for_approval_users, :as => :user, :partial => "user") ||\
content_tag(:li, "There are no users needing approval right now. Invite others to join Kandan!", class: 'no-users') %>
content_tag(:li, t('admin.warn_no_user'), class: 'no-users') %>
</ul>
</div>
<div class="approved-users">
<h3>All users</h3>
<ul class="users">
<%= render(:collection => @approved_users, :as => :user, :partial => "user") ||\
content_tag(:li, "There are no users. Invite others to join Kandan!", class: 'no-users') %>
content_tag(:li, t('admin.warn_no_approved_user'), class: 'no-users') %>
</ul>
</div>
</div>
6 changes: 3 additions & 3 deletions app/views/devise/confirmations/new.html.erb
@@ -1,12 +1,12 @@
<h2>Resend confirmation instructions</h2>
<h2><%= t('devise.confirmations.resend_confirm.head') %></h2>

<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>

<div><%= f.label :email %><br />
<%= f.email_field :email %></div>

<div><%= f.submit "Resend confirmation instructions" %></div>
<div><%= f.submit t('devise.confirmations.resend_confirm.button') %></div>
<% end %>
<%= render :partial => "devise/shared/links" %>
<%= render :partial => "devise/shared/links" %>
4 changes: 2 additions & 2 deletions app/views/devise/mailer/confirmation_instructions.html.erb
@@ -1,5 +1,5 @@
<p>Welcome <%= @resource.email %>!</p>

<p>You can confirm your account through the link below:</p>
<%= t('devise.mailer.confirmation_instructions.message.html') %>

<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
<p><%= link_to t('devise.mailer.confirmation_instructions.message.link'), confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
7 changes: 3 additions & 4 deletions app/views/devise/mailer/reset_password_instructions.html.erb
@@ -1,8 +1,7 @@
<p>Hello <%= @resource.email %>!</p>

<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
<%= t('devise.mailer.reset_password_instructions.message.html') %>

<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @token) %></p>
<p><%= link_to t(devise.mailer.reset_password_instructions.link'), edit_password_url(@resource, :reset_password_token => @token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
<%= t('devise.mailer.reset_password_instructions.note.html') %>
6 changes: 2 additions & 4 deletions app/views/devise/mailer/unlock_instructions.html.erb
@@ -1,7 +1,5 @@
<p>Hello <%= @resource.email %>!</p>

<p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
<%= t('devise.mailer.unlock_instructions.message.html') %>

<p>Click the link below to unlock your account:</p>

<p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
<p><%= link_to t('devise.mailer.unlock_instructions.message.link'), unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
10 changes: 5 additions & 5 deletions app/views/devise/passwords/edit.html.erb
@@ -1,20 +1,20 @@
<div class="devise">

<h2>Change your password</h2>
<h2><%= t('devise.passwords.edit.head')</h2>
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
<div class="form-group">
<%= f.label :password, "New password", :class => "control-label" %>
<%= f.label :password, t('devise.passwords.edit.new'), :class => "control-label" %>
<%= f.password_field :password, :class => "form-control" %>
</div>
<div class="form-group">
<%= f.label :password_confirmation, "Confirm new password", :class => "control-label" %>
<%= f.label :password_confirmation, t('devise.passwords.edit.confirm'), :class => "control-label" %>
<%= f.password_field :password_confirmation, :class => "form-control" %>
</div>
<p><%= f.submit "Change my password", :class => "btn btn-primary" %></p>
<p><%= f.submit t('devise.passwords.edit.submit'), :class => "btn btn-primary" %></p>
<% end %>
<p><%= render :partial => "devise/shared/links" %></p>
<p><%= render :partial => "devise/shared/links" %></p>
6 changes: 3 additions & 3 deletions app/views/devise/passwords/new.html.erb
@@ -1,12 +1,12 @@
<div class="devise">
<h3 class="heading">Forgot Password?</h3>
<h3 class="heading"><%= t('devise.passwords.new.head')</h3>
<%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>
<div class="form-group">
<%= label_tag :email, "Email", :class => "control-label" %>
<%= label_tag :email, t('devise.passwords.new.email'), :class => "control-label" %>
<%= f.text_field :email, :autofocus => true, :placeholder => 'jsmith@example.com', :class => "form-control" %>
</div>
<p><%= f.submit "Submit", :class => "btn btn-primary" %></p>
<p><%= f.submit t('devise.passwords.new.submit'), :class => "btn btn-primary" %></p>
<% end %>
<p><%= render :partial => "devise/shared/links" %></p>
</div>
22 changes: 11 additions & 11 deletions app/views/devise/registrations/edit.html.erb
Expand Up @@ -4,45 +4,45 @@
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put , :role => "form"}) do |f| %>
<div class="devise">
<h3 class="heading">Edit <%= resource_name.to_s.humanize %></h3>
<h3 class="heading"><%= t('devise.registrations.edit') %><%= resource_name.to_s.humanize %></h3>
<%= devise_error_messages! %>
<div class="form-group">
<%= label_tag :first_name, "First Name", :class => "control-label" %>
<%= label_tag :first_name, t('devise.registrations.first_name'), :class => "control-label" %>
<%= f.text_field :first_name, :class => "form-control", :placeholder => "John" %>
</div>
<div class="form-group">
<%= label_tag :last_name, "Last Name", :class => "control-label" %>
<%= label_tag :last_name, t('devise.registrations.last_name'), :class => "control-label" %>
<%= f.text_field :last_name, :class => "form-control", :placeholder => "Smith" %>
</div>
<div class="form-group">
<%= label_tag :email, "Email", :class => "control-label" %>
<%= label_tag :email, t('devise.registrations.email'), :class => "control-label" %>
<%= f.email_field :email, :class => "form-control", :placeholder => "jsmith@example.com" %>
</div>
<div class="form-group">
<%= label_tag :password, "Password", :class => "control-label" %>
<%= label_tag :password, t('devise.registrations.password'), :class => "control-label" %>
<%= f.password_field :password , :placeholder => 'New Password', :class => "form-control" %>
<div class="note"><i>(leave blank if you don't want to change it)</i></div>
</div>
<div class="form-group">
<%= label_tag :password_confirmation, "Password Confirmation", :class => "control-label" %>
<%= label_tag :password_confirmation, t('devise.registrations.password_confirmation'), :class => "control-label" %>
<%= f.password_field :password_confirmation, :class => "form-control", :placeholder => 'New Password Confirmation' %>
</div>
<div class="form-group">
<%= label_tag :avatar_url, "Avatar URL", :class => "control-label" %>
<%= label_tag :avatar_url, t('devise.registrations.avatar_url'), :class => "control-label" %>
<%= f.url_field :avatar_url, :class => "form-control", :placeholder => 'http://www.gravatar.com/avatar/XXXXXXXXX' %>
<div class="note"><i>(Avatar URL replaces your gravatar image)</i></div>
</div>
<div class="form-group">
<%= label_tag :current_password, "Current Password", :class => "control-label" %>
<%= label_tag :current_password, t('devise.registrations.current_password'), :class => "control-label" %>
<%= f.password_field :current_password, :class => "form-control", :placeholder => 'Current Password' %>
<div class="note"><i>(Enter your current password to confirm your changes)</i></div>
</div>
<p><%= link_to "Back", :back, :class => "btn btn-info" %>&nbsp;<%= f.submit "Update" , :class => "btn btn-primary" %></p>
</div>
<div class="devise">
<h3 class="heading">Cancel My Account.</h3>
<p>Unhappy with your service? We hate to see you go!<p>
<p><%= link_to "Cancel my account", registration_path(resource_name), :class => "btn btn-danger", :confirm => "Are you sure you want to delete your account?", :method => :delete %></p>
<h3 class="heading"><%= t('devise.registrations.cancel_account.head') %></h3>
<%= t('devise.registrations.cancel_account.html') %>
<p><%= link_to t('devise.registrations.cancel_account.link'), registration_path(resource_name), :class => "btn btn-danger", :confirm => "Are you sure you want to delete your account?", :method => :delete %></p>
<% end %>


Expand Down
16 changes: 8 additions & 8 deletions app/views/devise/registrations/new.html.erb
@@ -1,32 +1,32 @@
<div class="devise">
<h3 class="heading">Register an Account</h3>
<h3 class="heading"><%= t('devise.registrations.register_account') %></h3>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div class="form-group">
<%= label_tag :first_name, "First Name", :class => "control-label" %>
<%= label_tag :first_name, t('devise.registrations.first_name'), :class => "control-label" %>
<%= f.text_field :first_name, :class => "form-control", :placeholder => 'John' %>
</div>
<div class="form-group">
<%= label_tag :last_name, "Last Name", :class => "control-label" %>
<%= label_tag :last_name, t('devise.registrations.last_name'), :class => "control-label" %>
<%= f.text_field :last_name, :class => "form-control", :placeholder => 'Smith' %>
</div>
<div class="form-group">
<%= label_tag :email, "Email", :class => "control-label" %>
<%= label_tag :email, t('devise.registrations.email'), :class => "control-label" %>
<%= f.email_field :email, :class => "form-control", :placeholder => 'jsmith@example.com' %>
</div>
<div class="form-group">
<%= label_tag :password, "Username", :class => "control-label" %>
<%= label_tag :password, t('devise.registrations.username'), :class => "control-label" %>
<%= f.text_field :username, :class => "form-control", :placeholder => 'jsmith' %>
</div>
<div class="form-group">
<%= label_tag :password, "Password", :class => "control-label" %>
<%= label_tag :password, t('devise.registrations.password'), :class => "control-label" %>
<%= f.password_field :password, :class => "form-control", :placeholder => 'Something Memorable!' %>
</div>
<div class="form-group">
<%= label_tag :password, "Password Confirmation", :class => "control-label" %>
<%= label_tag :password, t('devise.registrations.password_confirmation'), :class => "control-label" %>
<%= f.password_field :password_confirmation, :class => "form-control", :placeholder => 'Something Memorable!' %>
</div>
<p><%= f.submit "Register", :class => "btn btn-primary" %></p>
<p><%= f.submit t('devise.registrations.register'), :class => "btn btn-primary" %></p>
<% end %>
<p><%= render :partial => "devise/shared/links" %></p>
</div>
8 changes: 4 additions & 4 deletions app/views/main/_sidebar.html.erb
Expand Up @@ -5,10 +5,10 @@
<%= current_user.full_name_or_username %>
</a>
<ul class="user-menu">
<li><%= link_to 'Admin console', admin_root_path if current_user.is_admin? %></li>
<li><%= link_to 'Edit Account', users_edit_path %></li>
<li><%= link_to 'Logout', destroy_user_session_path, :method => :delete %></li>
<li><%= link_to 'About Kandan', about_path %></li>
<li><%= link_to t('main.admin_console'), admin_root_path if current_user.is_admin? %></li>
<li><%= link_to t('main.edit_account'), users_edit_path %></li>
<li><%= link_to t('main.logout'), destroy_user_session_path, :method => :delete %></li>
<li><%= link_to t('main.about_kandan'), about_path %></li>
</ul>
</div>
<div class="widgets"></div>
10 changes: 5 additions & 5 deletions app/views/sessions/new.html.erb
@@ -1,18 +1,18 @@
<div class="devise">
<h3 class="heading">Sign In</h3>
<h3 class="heading"><%= t('sessions.title') %></h3>
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :role => :form) do |f| %>
<div class="form-group">
<%= label_tag :username, "Username", :class => "control-label" %>
<%= label_tag :username, t('sessions.username'), :class => "control-label" %>
<%= f.text_field :username, :autofocus => true, :placeholder => 'jsmith', :class => "form-control" %>
</div>
<div class="form-group">
<%= label_tag :password, "Password", :class => "control-label" %>
<%= label_tag :password, t('sessions.password'), :class => "control-label" %>
<%= f.password_field :password, :class => "form-control"%>
</div>
<label class="checkbox">
<input type="checkbox" value="remember-me"> Remember me
<input type="checkbox" value="remember-me"><%= t('sessions.rememberme') %>
</label>
<%= f.submit "Sign in", :class => "btn btn-primary" %>
<%= f.submit t('sessions.submit'), :class => "btn btn-primary" %>
<% end %>
<%= render :partial => "devise/shared/links" %>
</div>
3 changes: 3 additions & 0 deletions config/application.rb
Expand Up @@ -43,6 +43,9 @@ class Application < Rails::Application
# 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.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
config.i18n.default_locale = :en
config.i18n.enforce_available_locales = true

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
Expand Down
46 changes: 46 additions & 0 deletions config/locales/admin/admin.pot
@@ -0,0 +1,46 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2015-03-11 15:06+0900\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"

msgctxt "admin:max_number_of_rooms"
msgid "Max number of rooms"
msgstr ""

msgctxt "admin:public_site"
msgid "Public site"
msgstr ""

msgctxt "admin:site_settings"
msgid "Site settings"
msgstr ""

msgctxt "admin:users_waiting_approval"
msgid "Users waiting for approval"
msgstr ""

msgctxt "admin:warn_no_user"
msgid "There are no users needing approval right now. Invite others to join Kandan!"
msgstr ""

msgctxt "admin:warn_no_approved_user"
msgid "There are no users. Invite others to join Kandan!"
msgstr ""

msgctxt "admin:disable_connect"
msgid "disable connect/disconnect activity"
msgstr ""

0 comments on commit 14d3d8d

Please sign in to comment.