Init version of i18n support.

This commit is contained in:
Martin Edenhofer 2012-04-30 21:14:40 +02:00
parent df1493fb81
commit e86204db76
11 changed files with 72 additions and 52 deletions

View file

@ -2,7 +2,7 @@ class App.Controller extends Spine.Controller
# add @title methode to set title # add @title methode to set title
title: (name) -> title: (name) ->
$('html head title').html( Config.product_name + ' - ' + name ) $('html head title').html( Config.product_name + ' - ' + T(name) )
# add @notify methode to create notification # add @notify methode to create notification
notify: (data) -> notify: (data) ->

View file

@ -96,7 +96,7 @@ class Index extends App.Controller
Spine.trigger 'notify:removeall' Spine.trigger 'notify:removeall'
Spine.trigger 'notify', { Spine.trigger 'notify', {
type: 'success', type: 'success',
msg: 'Login successfully! Have a nice day!', msg: T('Login successfully! Have a nice day!'),
} }
# redirect to # # redirect to #
@ -115,12 +115,11 @@ class Index extends App.Controller
Spine.trigger 'notify:removeall' Spine.trigger 'notify:removeall'
Spine.trigger 'notify', { Spine.trigger 'notify', {
type: 'error', type: 'error',
msg: 'Wrong Username and Password combination.', msg: T('Wrong Username and Password combination.'),
} }
# rerender login page # rerender login page
@render( @render(
msg: 'Wrong Username and Password combination.',
username: @username username: @username
) )

View file

@ -22,9 +22,4 @@ class Index extends Spine.Controller
# redirect to login # redirect to login
@navigate 'login' @navigate 'login'
Config.Routes['logout'] = Index Config.Routes['logout'] = Index
#class App.Logout extends App.Router
# routes:
# 'logout': Index
#Config.Controller.push App.Logout

View file

@ -176,7 +176,8 @@ class App.Navigation extends App.Controller
Config.NavBar['TicketOverview' + item.url] = { Config.NavBar['TicketOverview' + item.url] = {
prio: item.prio, prio: item.prio,
parent: '#ticket/view', parent: '#ticket/view',
name: T(item.name) + ' (' + item.count + ')', name: item.name,
count: item.count,
target: '#ticket/view/' + item.url, target: '#ticket/view/' + item.url,
role: ['Agent'], role: ['Agent'],
} }

View file

@ -6,15 +6,15 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="span12"> <div class="span12">
<p>Sign in with</p> <p><%= T('Sign in with') %></p>
<form id="login" class="form-search"> <form id="login" class="form-search">
<input name="username" type="text" class="input span3" placeholder="Username or email" value="<%= @item.username %>" autocapitalize="off"/> <input name="username" type="text" class="input span3" placeholder="<%= T('Username or email') %>" value="<%= @item.username %>" autocapitalize="off"/>
<input name="password" type="password" class="input span3" placeholder="Password"/> <input name="password" type="password" class="input span3" placeholder="<%= T('Password') %>"/>
<button class="btn btn-primary" type="submit">Sign in</button> <button class="btn btn-primary" type="submit"><%= T('Sign in') %></button>
<div> <div>
<span class="small"><input name="remember_me" value="1" type="checkbox"/> Remember me</span> <span class="small"><input name="remember_me" value="1" type="checkbox"/> <%= T('Remember me') %></span>
<span class="small">&middot;</span> <span class="small">&middot;</span>
<a href="#reset_password" class="small">Forgot password?</a> <a href="#reset_password" class="small"><%= T('Forgot password?') %></a>
</div> </div>
</form> </form>
</div> </div>
@ -24,16 +24,16 @@
<% if !_.isEmpty(@auth_providers): %> <% if !_.isEmpty(@auth_providers): %>
<div class="row"> <div class="row">
<div class="span12"> <div class="span12">
<p>--- or ---</p> <p>--- <%= T('or') %> ---</p>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="span12"> <div class="span12">
<p>Sign in using</p> <p><%= T('Sign in using') %></p>
<ul> <ul>
<% for auth_provider in @auth_providers: %> <% for auth_provider in @auth_providers: %>
<li><a href="<%= auth_provider.url %>"><%= auth_provider.name %></a></li> <li><a href="<%= auth_provider.url %>"><%= T(auth_provider.name) %></a></li>
<% end %> <% end %>
</ul> </ul>
</div> </div>
@ -42,14 +42,14 @@
<div class="row"> <div class="row">
<div class="span12"> <div class="span12">
<p>--- or ---</p> <p>--- <%= T('or') %> ---</p>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="span12"> <div class="span12">
<p>New to <%= Config.product_name %>, join today!</p> <p><%= T('New to') %> <%= Config.product_name %>, <%= T('join today!') %></p>
<p><a href="#signup" class="btn">Sign up</a> <p><a href="#signup" class="btn"><%= T('Sign up') %></a>
</div> </div>
</div> </div>

View file

@ -15,7 +15,7 @@
<% if item.navheader: %> <% if item.navheader: %>
<li class="nav-header"><%= T(item.navheader) %></li> <li class="nav-header"><%= T(item.navheader) %></li>
<% end %> <% end %>
<li><a href="<%= item.target %>"><%= T(item.name) %></a></li> <li><a href="<%= item.target %>"><%= T(item.name) %><% if item['count'] isnt undefined: %> <span class="count">(<%= item['count'] %>)</span><% end %></a></li>
<% end %> <% end %>
</ul> </ul>
</li> </li>
@ -41,7 +41,7 @@
<% if item.navheader: %> <% if item.navheader: %>
<li class="nav-header"><%= T(item.navheader) %></li> <li class="nav-header"><%= T(item.navheader) %></li>
<% end %> <% end %>
<li><a href="<%= item.target %>"><%= T(item.name) %></a></li> <li><a href="<%= item.target %>"><%= T(item.name) %><% if item['count'] isnt undefined: %> <span class="count">(<%= item['count'] %>)</span><% end %></a></li>
<% end %> <% end %>
</ul> </ul>
</li> </li>

View file

@ -1,13 +1,13 @@
<div class="hero-unit"> <div class="hero-unit">
<h1>Join <%= Config.product_name %><small></small></h1> <h1><%= T('Join') %> <%= Config.product_name %><small></small></h1>
<div class="container"> <div class="container">
<form class="form-horizontal"> <form class="form-horizontal">
<p> <p>
<%- @form %> <%- @form %>
</p> </p>
<a href="#/" class="btn cancel">Cancel</a> <a href="#/" class="btn cancel"><%= T('Cancel') %></a>
<button class="btn btn-primary submit">Create my account</button> <button class="btn btn-primary submit"><%= T('Create my account') %></button>
</form> </form>
</div> </div>
</div> </div>

View file

@ -41,7 +41,7 @@
<% else: %> <% else: %>
<span title="<%= T(item['title']) %>" style="<%= item['style'] %>" data-type="<%= item['data'] %>" class="<%= item['class'] %>"> <span title="<%= T(item['title']) %>" style="<%= item['style'] %>" data-type="<%= item['data'] %>" class="<%= item['class'] %>">
<% end %> <% end %>
<%= T(item['name']) %> <%= T(item['name']) %> <% if item['count'] isnt undefined: %><span class="count">(<%= item['count'] %>)</span><% end %>
<% if item['url']: %> <% if item['url']: %>
</a> </a>
<% else: %> <% else: %>

View file

@ -26,7 +26,7 @@
<% else: %> <% else: %>
<span title="<%= T(item['title']) %>" style="<%= item['style'] %>" data-type="<%= item['data'] %>" class="<%= item['class'] %>"> <span title="<%= T(item['title']) %>" style="<%= item['style'] %>" data-type="<%= item['data'] %>" class="<%= item['class'] %>">
<% end %> <% end %>
<%= T(item['name']) %> <%= T(item['name']) %> <% if item['count'] isnt undefined: %><span class="count">(<%= item['count'] %>)</span><% end %>
<% if item['url']: %> <% if item['url']: %>
</a> </a>
<% else: %> <% else: %>

View file

@ -42,6 +42,7 @@ var Trans = {
'Zip': 'PLZ', 'Zip': 'PLZ',
'City': 'Stadt', 'City': 'Stadt',
'Note': 'Notiz', 'Note': 'Notiz',
'note': 'Notiz',
'New User': 'Neuer Benutzer', 'New User': 'Neuer Benutzer',
'new': 'neu', 'new': 'neu',
'closed': 'geschlossen', 'closed': 'geschlossen',
@ -67,6 +68,19 @@ var Trans = {
'To': 'An', 'To': 'An',
'Customer': 'Kunde', 'Customer': 'Kunde',
'Linked Accounts': 'Verknüpfte Accounts', 'Linked Accounts': 'Verknüpfte Accounts',
'Sign in with': 'Anmelden mit',
'Username or email': 'Benutzer oder Email',
'Remember me': 'An mich erinnern',
'Forgot password?': 'Passwort vergessen?',
'Sign in using': 'Anmelden über',
'New to': 'Neu bei',
'join today!': 'werde Teil!',
'Sign up': 'Registrieren',
'Sign in': 'Anmelden',
'Create my account': 'Meinen Account erstellen',
'Login successfully! Have a nice day!': 'Anmeldung erfolgreich!',
'Wrong Username and Password combination.': 'Benutzername oder Password falsch.',
} }
var T = function(string) { var T = function(string) {
if ( Trans[string] !== undefined ) { if ( Trans[string] !== undefined ) {

View file

@ -168,32 +168,43 @@ class ApplicationController < ActionController::Base
# do not show password # do not show password
user['password'] = '' user['password'] = ''
# show linked topics and items
user['links'] = []
# TEMP: compat. reasons # TEMP: compat. reasons
user['preferences'] = {} if user['preferences'] == nil user['preferences'] = {} if user['preferences'] == nil
topic = { items = []
:title => 'Tickets', if user['preferences'][:tickets_open].to_i > 0
:items => [ item = {
{ :url => '',
:url => '', :name => 'open',
:name => 'open (' + user['preferences'][:tickets_open].to_s + ')', :count => user['preferences'][:tickets_open] || 0,
:title => 'Open Tickets', :title => 'Open Tickets',
:class => 'user-tickets', :class => 'user-tickets',
:data => 'open' :data => 'open'
}, }
{ items.push item
:url => '', end
:name => 'closed (' + user['preferences'][:tickets_closed].to_s + ')', if user['preferences'][:tickets_closed].to_i > 0
:title => 'Closed Tickets', item = {
:class => 'user-tickets', :url => '',
:data => 'closed' :name => 'closed',
} :count => user['preferences'][:tickets_closed] || 0,
] :title => 'Closed Tickets',
} :class => 'user-tickets',
user['links'].push topic :data => 'closed'
}
items.push item
end
# show linked topics and items
if items.count > 0
topic = {
:title => 'Tickets',
:items => items,
}
user['links'] = []
user['links'].push topic
end
return user return user
end end