Permalink
Browse files

adding japanese french

  • Loading branch information...
1 parent aaa6352 commit ea84c22eff03e5e78e99c4c983c488a1fca04aad Robert Sosinski committed Apr 1, 2012
@@ -48,7 +48,7 @@ Root.ListsViewModel = function() {
self.newTask.name("");
},
function(error) {
- Root.modalsViewModel.render("Error", error);
+ Root.modalsViewModel.error.render(error);
});
};
@@ -1,26 +1,28 @@
Root.ModalsViewModel = function() {
var self = this;
- self.header = ko.observable();
- self.list = ko.observable();
-
- self.render = function(header, body) {
- // format errors as a list, eg::
- // from: {"errors":{"name":["Name cant be blank", "Name must be unique"]}}
- // to: ["Name cant be blank", "Name must be unique"]
- var errors = _.reduce(body, function(memo, attr) {
- return _.map(_.keys(attr), function(field) {
- return attr[field];
- });
- }, []);
+ self.error = {
+ body: ko.observable(),
- self.header(header);
- self.list(errors);
- self.show();
- };
+ render: function(messages) {
+ // format errors as a list, eg::
+ // from: {"errors":{"name":["Name cant be blank", "Name must be unique"]}}
+ // to: ["Name cant be blank", "Name must be unique"]
+ var errors = _.reduce(messages, function(memo, attr) {
+ return _.map(_.keys(attr), function(field) {
+ return attr[field];
+ });
+ }, []);
+
+ errors = _.flatten(errors);
+
+ self.error.body(errors);
+ self.show('error');
+ }
+ }
- self.show = function() {
- $("#modal-view").modal({
+ self.show = function(type) {
+ $("#modal-" + type).modal({
keyboard: true
});
};
@@ -17,8 +17,8 @@ def default_url_options(options={})
def check_authentication
unless warden.authenticated?
- flash[:notice] = "You have to login before you can access your task list."
+ flash[:notice] = t('root.flash.notice.login_required')
redirect_to new_sessions_path
end
end
-end
+end
@@ -9,20 +9,20 @@ def new
def create
warden.authenticate!
- flash[:success] = "Welcome back #{warden.user.username}."
+ flash[:success] = t('root.flash.success.welcome_back', :username => warden.user.username)
redirect_to lists_path
end
def destroy
warden.logout
- flash[:notice] = "Thanks for dropping by."
+ flash[:notice] = t('root.flash.notice.goodbye')
redirect_to root_path
end
def failure
- flash.now[:error] = warden.message
+ flash.now[:error] = t(warden.message, :scope => 'root.flash.error')
render :new
end
@@ -10,14 +10,14 @@ def create
if @user.save
warden.set_user(@user)
- flash[:success] = "Hey #{@user.username}, welcome to Kiv7!"
+ flash[:success] = t('root.flash.success.welcome', :username => warden.user.username)
redirect_to lists_path
else
render :new
end
rescue
- flash.now[:error] = "Something went wrong, please try again."
+ flash.now[:error] = t('root.flash.error.something_else')
render :new
end
end
@@ -0,0 +1,22 @@
+<div id="modals-view">
+
+ <div id="modal-error" class="modal" style="display: none;">
+ <div class="modal-header">
+ <a class="close" data-dismiss="modal">×</a>
+ <h3><%= t 'root.layouts.namespace.modals.error.header' %></h3>
+ </div>
+ <div class="modal-body">
+ <ul data-bind="foreach: error.body">
+ <li data-bind="text: $data"></li>
+ </ul>
+ </div>
+ <div class="modal-footer">
+ <a href="#" class="btn" data-dismiss="modal">Close</a>
+ </div>
+ </div>
+
+</div>
+
+<% content_for :bindings do %>
+ ko.applyBindings(Root.modalsViewModel = new Root.ModalsViewModel(), ko.element("modals-view"));
+<% end %>
@@ -42,7 +42,7 @@
</footer>
</div>
- <%= render :partial => 'root/layouts/modal' %>
+ <%= render :partial => 'root/layouts/modals' %>
<script type="text/javascript">
$(function() {
@@ -4,9 +4,14 @@
<%= t '.list.name' %>
<small>
<span data-bind="visible: incompleteTasks().length > 0">
-
- has <span data-bind="text: incompleteTasks().length"></span> <span data-bind="text: incompleteTasks().length == 1 ? 'task' : 'tasks'"></span> left
-
+ <% case I18n.locale %>
+ <% when :en %>
+ has <span data-bind="text: incompleteTasks().length"></span> <span data-bind="text: incompleteTasks().length == 1 ? 'task' : 'tasks'"></span> left
+ <% when :fr %>
+ a <span data-bind="text: incompleteTasks().length"></span> <span data-bind="text: incompleteTasks().length == 1 ? 'tâche à gauche' : 'tâches laissées'"></span>
+ <% when :jp %>
+ には <span data-bind="text: incompleteTasks().length"></span> タスクがあります
+ <% end %>
</span>
<span data-bind="visible: incompleteTasks().length == 0"><%= t '.list.is_complete' %></span>
@@ -8,7 +8,7 @@
<p>
<%= link_to t('root.layouts.namespace.signup'), new_users_path, :class => "btn btn-primary btn-large" %>
- <span class="welcome-or"><%= t 'root.words.or' %></span>
+ <span class="welcome-or"><%= t 'root.word.or' %></span>
<%= link_to t('root.layouts.namespace.login'), new_sessions_path, :class => "btn btn-large" %>
</p>
</div>
@@ -18,6 +18,6 @@ def valid?
def authenticate!
user = User.authenticate(params["session"]["username"], params["session"]["password"])
- user ? success!(user) : fail!("Invalid username and/or password.")
+ user ? success!(user) : fail!(:invalid_username_or_password)
end
end
View
@@ -1,9 +1,20 @@
en:
root:
- words:
+ word:
or: or
task: task
tasks: tasks
+
+ flash:
+ success:
+ welcome: "Hey %{username}, welcome to Kiv7!"
+ welcome_back: "Welcome back %{username}."
+ notice:
+ goodbye: Thanks for dropping by.
+ login_required: You have to login before you can access your task list.
+ error:
+ invalid_username_or_password: Invalid username or password.
+ something_else: Something went wrong, please try again.
layouts:
namespace:
@@ -21,6 +32,10 @@ en:
All code is open sourced using an [MIT license](http://github.com/robertsosinski/kiv7/blob/master/LICENSE) and can be found on [GitHub](http://github.com/robertsosinski/kiv7).
__NOTICE:__ This website is a technology demo, any data you put into this application can be lost at any time.
+
+ modals:
+ error:
+ header: Error
pages:
welcome:
@@ -36,4 +51,4 @@ en:
name: Your List
is_complete: is complete
new_task:
- placeholder: What needs to be done?
+ placeholder: What needs to be done?
View
@@ -1,9 +1,20 @@
fr:
root:
- words:
+ word:
or: ou
task: tâche
tasks: tâches
+
+ flash:
+ success:
+ welcome: "Hé %{username} bienvenue à Kiv7!"
+ welcome_back: "Accueillir à nouveau %{username}."
+ notice:
+ goodbye: Merci d'être passé par.
+ login_required: Vous devez vous connecter avant de pouvoir accéder à votre liste de tâches.
+ error:
+ invalid_username_or_password: Nom d'utilisateur ou mot de passe non valide.
+ something_else: Quelque chose s'est mal passé, s'il vous plaît essayez de nouveau.
layouts:
namespace:
@@ -21,6 +32,10 @@ fr:
Tout le code est open source en utilisant un [licence MIT](http://github.com/robertsosinski/kiv7/blob/master/LICENSE) et peut être trouvée sur [GitHub](http://github.com/robertsosinski/kiv7).
__AVIS:__ Ce site est une démo technologique, toutes les données que vous mettez dans cette application peut être perdu à tout moment.
+
+ modals:
+ error:
+ header: Erreur
pages:
welcome:
@@ -36,4 +51,4 @@ fr:
name: Votre Liste
is_complete: est terminée
new_task:
- placeholder: Qu'est-ce qui doit être fait?
+ placeholder: Qu'est-ce qui doit être fait?
View
@@ -1,10 +1,21 @@
jp:
root:
- words:
+ word:
or: または
task: タスク
tasks: タスク
+ flash:
+ success:
+ welcome: "ヘイ%{username}、Kiv7へようこそ!"
+ welcome_back: "ようこそバック%{username}。"
+ notice:
+ goodbye: 立ち寄ってくれてありがとう。
+ login_required: あなたは、あなたのタスクリストにアクセスする前に、ログインする必要があります。
+ error:
+ invalid_username_or_password: 無効なユーザー名またはパスワードを入力します。
+ something_else: 何かが間違っていた、もう一度試してください。
+
layouts:
namespace:
language: 言語
@@ -21,6 +32,10 @@ jp:
すべてのコードはオープン[MITライセンス](http://github.com/robertsosinski/kiv7/blob/master/LICENSE) を使用して取り込まれ [GitHubに](http://github.com/robertsosinski/kiv7) に記載されています。
__注意:__ このサイトは技術デモでは、このアプリケーションに置かれた任意のデータはいつでも失われる可能性があります。
+
+ modals:
+ error:
+ header: エラー
pages:
welcome:

0 comments on commit ea84c22

Please sign in to comment.