Skip to content

Commit 570daff

Browse files
committed
Merge pull request VizirAdmin#1 from u2ix/master
Translated app to english
2 parents b005cc9 + 8e9e314 commit 570daff

File tree

10 files changed

+140
-50
lines changed

10 files changed

+140
-50
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
class ApplicationController < ActionController::Base
22
protect_from_forgery
3+
before_filter :set_language
4+
35
def can_access?
46
current_user.id == @note.user_id
57
end
68

9+
10+
private
11+
def set_language
12+
if !current_user.nil?
13+
I18n.locale = current_user.language || I18n.default_locale
14+
end
15+
end
716
end
817

app/models/user.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ class User < ActiveRecord::Base
66
:recoverable, :rememberable, :trackable, :validatable
77

88
# Setup accessible (or protected) attributes for your model
9-
attr_accessible :email, :password, :password_confirmation, :remember_me, :username
9+
attr_accessible :email, :password, :password_confirmation, :remember_me, :username, :language
1010

1111
validates_presence_of :username
1212
validates_uniqueness_of :username, :case_sensitive => false
1313
validates_format_of :username, :with => /^[A-Za-z\d_]+$/
1414

15+
def self.languages
16+
{'pt-BR' => 'Portugues', 'en' => 'English'}
17+
end
1518
end
1619

app/views/devise/registrations/edit.html.haml

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
= I18n.t('devise.registrations.hint_current_password')
4141
%br/
4242
= f.password_field :current_password
43+
%p
44+
= f.label :language
45+
%br= f.select :language, User.languages.invert
4346
%p= f.submit I18n.t('update')
4447
= link_to I18n.t('back'), root_path
4548

app/views/devise/sessions/new.html.haml

+9-13
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,15 @@
2323
%br
2424
= link_to I18n.t('user.forgot_password'), new_password_path(resource_name)
2525
%br
26+
%p= I18n.t('user.demo').html_safe
2627
%p
27-
Quer conhecer antes o Snote?
28-
%br
29-
Acesse com a conta demo:
30-
%br
31-
%b E-mail:
32-
%i demo@snote.com
33-
%br
34-
%b Senha:
35-
%i snote11
28+
%b E-mail:
29+
%i demo@snote.com
30+
%br
31+
%b= I18n.t('user.password')+':'
32+
%i snote11
3633
#credit
3734
%p
38-
<strong>Um #{link_to "projeto", "http://github.com/Vizir/snote"} <i>open source</i> desenvolvido por:</strong> #{link_to "Fabrício Ferrari de Campos", "http://twitter.com/fabricioffc"}.
39-
40-
<strong>Uma iniciativa do time do</strong> #{link_to "Vizir", "http://www.vizir.com.br"}.
41-
35+
%strong= t('credit.footer', :project_link => link_to(t('credit.project'), 'http://github.com/Vizir/snote'), :author => link_to('Fabrício Ferrari de Campos', 'http://twitter.com/fabricioffc')).html_safe
36+
%br
37+
%strong= t('credit.initiative', :link => link_to("Vizir", "http://www.vizir.com.br")).html_safe

app/views/notes/_form.html.haml

+27-32
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,34 @@
2222
= link_to I18n.t('back'), notes_path
2323
.Right
2424
#help_text
25-
%h2 Formatando o texto
26-
%p
27-
A formatação é feita com o
28-
%em
29-
= link_to 'Textile', "http://redcloth.org/hobix.com/textile/", :target => "_blank"
30-
\.
31-
%p
32-
Possibilitando uma formatação simples, atráves de marcações fáceis.
33-
34-
%p
35-
Segue alguns exemplos:
36-
25+
%h2= t('format.title')
26+
%p= t('format.desc', :textile_link => link_to('Textile', "http://redcloth.org/hobix.com/textile/", :target => "_blank")).html_safe
27+
%p= t('format.examples')
3728
.textileexamples
3829
%p
39-
*negrito* → <strong>negrito</strong>
40-
%br
41-
_itálico_ →
42-
%em
43-
itálico
44-
%br
30+
= "*"+t('format.bold')+"*"
31+
32+
%strong= t('format.bold')
33+
%p
34+
= "_"+t('format.italic')+"_"
35+
36+
%em= t('format.italic')
37+
%p
4538
"link":http://google.com →
4639
= link_to "link","http://google.com", :target => "_blank"
47-
%br
48-
pre. → texto pré-formatado (<i>pre</i> do html)
49-
%br
50-
* → lista com marcador
51-
%br
52-
** → segundo nível
53-
%br
54-
\# → lista numerada
55-
%br
56-
\## → segundo nível
57-
%br
58-
Veja mais marcações em:
59-
= link_to "exemplo",notes_example_path, :target=> "_blank"
60-
40+
%p
41+
pre. →
42+
= t('format.pre')
43+
%p
44+
* →
45+
= t('format.ul')
46+
%p
47+
** →
48+
= t('format.2ndlevel')
49+
%p
50+
\# →
51+
= t('format.ol')
52+
%p
53+
\## →
54+
= t('format.2ndlevel')
55+
%p= t('format.see', :link => link_to(t('format.example'),notes_example_path, :target=> "_blank")).html_safe

config/locales/devise.en.yml

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ en:
3333
inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
3434
updated: 'You updated your account successfully.'
3535
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
36+
hint_alter_password: "(leave it blank if you don't wan't to change your password.)"
37+
hint_current_password: "(needed for updating your account)"
3638
unlocks:
3739
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
3840
unlocked: 'Your account was successfully unlocked. You are now signed in.'

config/locales/en.yml

+57-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,58 @@
1-
# Sample localization file for English. Add more files in this directory for other locales.
2-
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3-
41
en:
5-
hello: "Hello world"
2+
# snote
3+
please_wait: "Wait..."
4+
please_wait_searching: "Searching..."
5+
confirmation: "Are you shure?"
6+
back: "Back"
7+
error: "Error"
8+
login: "Login"
9+
update: "Refresh"
10+
logout: "Logout"
11+
search: "Search"
12+
my_new_note: "Check my new note:"
13+
note:
14+
new: "New"
15+
edit: "Edit"
16+
delete: "Remove"
17+
creating: "Create note"
18+
editing: "Edit note"
19+
notags: "No tags."
20+
zero_notes: "<div>There are no notes.</div><div>Click on button <b>new</b> and create your first note.</div>"
21+
textk: "Text*"
22+
not_found: "<div>Note not found.</div><div><a href='/'><b>*Back*</b></a></div>"
23+
powered_by: "Powerd by:"
24+
share: "Share"
25+
format:
26+
title: "Formatting text"
27+
desc: "Text is formatted using %{textile_link} markup.<br>This makes it simple to apply formattings using an easy markup."
28+
examples: "Some examples:"
29+
bold: "Bold"
30+
italic: "italic"
31+
pre: "pre formatting like in html"
32+
ul: "bulleted list"
33+
ol: "numbered list"
34+
2ndlevel: "2nd level"
35+
see: "See the example note: %{link}"
36+
example: "example"
37+
user:
38+
creating: "Register"
39+
sign_up: "Register"
40+
edit: "Edit"
41+
edit_link: "Account settings"
42+
editing: "Account settings"
43+
forgot_password: "Forgot password?"
44+
info_to_recover_password: "Email will be send to your inbox"
45+
recover_password: "You will recieve a email for recover your account"
46+
update_password: "Change password"
47+
password: "Password"
48+
title_to_change_password: "Change password"
49+
anonymous: "Anonym"
50+
demo: "Like to try out snote?<br />Login with the demo account:"
51+
credit:
52+
footer: "An open source %{project_link} by %{author}"
53+
project: "project"
54+
initiative: "An initiative of the team %{link}"
55+
helpers:
56+
submit:
57+
create: "Create %{model}"
58+
update: "Update %{model}"

config/locales/pt-BR.yml

+19
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ pt-BR:
2222
not_found: "<div>Nenhuma anotação foi encontrada.</div><div><a href='/'><b>*Voltar*</b></a></div>"
2323
powered_by: "Criada por:"
2424
share: "Compartilhar"
25+
format:
26+
title: "Formatando o texto"
27+
desc: "A formatação é feita com o %{textile_link}.<br>Possibilitando uma formatação simples, atráves de marcações fáceis."
28+
examples: "Segue alguns exemplos:"
29+
bold: "negrito"
30+
italic: "itálico"
31+
pre: "texto pré-formatado (pre do html)"
32+
ul: "lista com marcador"
33+
ol: "lista numerada"
34+
2ndlevel: "segundo nível"
35+
see: "Veja mais marcações em: %{link}"
36+
example: "exemplo"
2537
user:
2638
creating: "Registro"
2739
sign_up: "Registrar-se"
@@ -34,6 +46,12 @@ pt-BR:
3446
update_password: "Alterar a minha senha"
3547
title_to_change_password: "Alteração da senha de acesso"
3648
anonymous: "Anônimo"
49+
demo: "Quer conhecer antes o Snote?<br/>Acesse com a conta demo:"
50+
password: "Senha"
51+
credit:
52+
footer: "Um %{project_link} <i>open source</i> desenvolvido por: %{author}"
53+
project: "projeto"
54+
initiative: "Uma iniciativa do time do %{link}"
3755
helpers:
3856
submit:
3957
create: "Criar %{model}"
@@ -194,6 +212,7 @@ pt-BR:
194212
password: "Senha"
195213
remember_me: "lembrar login?"
196214
username: "Usuário"
215+
language: "Linguagem"
197216
errors:
198217
template:
199218
header:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class AddLanguageToUsers < ActiveRecord::Migration
2+
def self.up
3+
add_column :users, :language, :string
4+
end
5+
6+
def self.down
7+
remove_column :users, :language
8+
end
9+
end

public/stylesheets/snote.css

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ position:absolute;
158158
#snote #help_text{min-width:200px;padding:5px 20px 0 9px;}
159159

160160
#snote .textileexamples{margin-left:15px}
161+
#snote .textileexamples p {margin:0;padding: 0;}
161162

162163
.Left{
163164
float:left;

0 commit comments

Comments
 (0)