Skip to content

Commit

Permalink
Kickstart localization with an example, added polish base locale
Browse files Browse the repository at this point in the history
  • Loading branch information
David FRANCOIS committed Jan 11, 2011
1 parent bf57d5a commit e135135
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 5 deletions.
14 changes: 13 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class ApplicationController < ActionController::Base
:authenticate,
:authorize,
:set_time_zone,
:remove_params
:remove_params,
:set_locale

def authenticate
if session[:current_user_id]
Expand Down Expand Up @@ -40,4 +41,15 @@ def remove_params
params.delete :skip_captcha
params.delete :skip_password
end

# Changes the locale if *locale* (en|fr|...) is passed as GET parameter
def set_locale
locale = params[:locale] or session[:locale]
locale = locale.to_sym if locale

if locale and I18n.available_locales.include?(locale)
I18n.locale = locale
session[:locale] = locale
end
end
end
8 changes: 4 additions & 4 deletions app/views/layouts/_user_informations.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
<p>
<% if @current_user %>
<p class="identification">
Signed-in as <%= link_to @current_user.account, edit_user_path %> - <%= link_to "Logout", session_path, :method => :delete %>
<%= t :signed_in_as %> <%= link_to @current_user.account, edit_user_path %> - <%= link_to t(:logout), session_path, :method => :delete %>
</p>
<p>
Your address : <span class="bitcoin-address" id="last-bitcoin-address"><%= @current_user.last_address %></span>
<%= t :your_last_address %> : <span class="bitcoin-address" id="last-bitcoin-address"><%= @current_user.last_address %></span>
<%= link_to image_tag('refresh.png'),
user_addresses_path,
:remote => true,
:method => :post,
:id => 'refresh-button',
:title => 'Generate a new receiving address, refresh at will' %>
:title => t(:generate_new_address_legend) %>
</p>
<% else %>
<%= link_to "Sign-up", new_user_path %> or <%= link_to "login", new_session_path %>
<%= link_to t(:sign_up), new_user_path %> | <%= link_to t(:sign_in), new_session_path %>
<% end %>
</p>
</div>
7 changes: 7 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,3 +263,10 @@ en:
new_password_confirmation: Confirmation


# layouts/user_informations.html
generate_new_address_legend: Generate a new receiving address, refresh at will
your_last_address: Your address
logout: Logout
signed_in_as: Signed-in as
sign_up: Sign-up
sign_in: Login
9 changes: 9 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,12 @@ fr:
<<: *errors_template
full_messages:
format: "%{attribute} %{message}"


# layouts/user_informations.html
generate_new_address_legend: Générer une nouvelle addresse de réception
your_last_address: Votre addresse
logout: Déconnexion
signed_in_as: Connecté en tant que
sign_up: S'enregistrer
sign_in: Se connecter
193 changes: 193 additions & 0 deletions config/locales/pl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
# Polish translations for Ruby on Rails
# by Jacek Becela (jacek.becela@gmail.com, http://github.com/ncr)
# Minor changes and adjustments for Rails 3 by Piotrek Okoński (http://github.com/pokonski)

pl:
date:
formats:
default: "%d-%m-%Y"
short: "%d %b"
long: "%B %d, %Y"

day_names: [niedziela, poniedziałek, wtorek, środa, czwartek, piątek, sobota]
abbr_day_names: [nie, pon, wto, śro, czw, pia, sob]

month_names: [~, styczeń, luty, marzec, kwiecień, maj, czerwiec, lipiec, sierpień, wrzesień, październik, listopad, grudzień]
abbr_month_names: [~, sty, lut, mar, kwi, maj, cze, lip, sie, wrz, paź, lis, gru]
order:
- :day
- :month
- :year

time:
formats:
default: "%a, %d %b %Y %H:%M:%S %z"
short: "%d %b %H:%M"
long: "%B %d, %Y %H:%M"
am: "przed południem"
pm: "po południu"

support:
array:
words_connector: ", "
two_words_connector: " i "
last_word_connector: " oraz "

select:
prompt: "Proszę wybrać"

number:
format:
separator: ","
delimiter: " "
precision: 3
significant: false
strip_insignificant_zeros: false

currency:
format:
format: "%u %n"
unit: "PLN"
separator: ","
delimiter: " "
precision: 2
significant: false
strip_insignificant_zeros: true

percentage:
format:
delimiter: ""

precision:
format:
delimiter: ""

human:
format:
delimiter: ""
precision: 3
significant: true
strip_insignificant_zeros: true
storage_units:
format: "%n %u"
units:
byte:
one: "bajt"
other: "bajty"
kb: "KB"
mb: "MB"
gb: "GB"
tb: "TB"
decimal_units:
format: "%n %u"
units:
unit: ""
thousand: Tysiąc
million: Milion
billion: Miliard
trillion: Trylion
quadrillion: Kwadrylion

datetime:
distance_in_words:
half_a_minute: "pół minuty"
less_than_x_seconds:
one: "mniej niż sekundę"
few: "mniej niż %{count} sekundy"
other: "mniej niż %{count} sekund"
x_seconds:
one: "1 sekunda"
few: "%{count} sekundy"
other: "%{count} sekund"
less_than_x_minutes:
one: "mniej niż minutę"
few: "mniej niż %{count} minuty"
other: "mniej niż %{count} minut"
x_minutes:
one: "1 minuta"
few: "%{count} minuty"
other: "%{count} minut"
about_x_hours:
one: "około godziny"
few: "około %{count} godziny"
other: "około %{count} godzin"
x_days:
one: "1 dzień"
few: "%{count} dni"
other: "%{count} dni"
about_x_months:
one: "około miesiąca"
few: "około %{count} miesiące"
other: "około %{count} miesięcy"
x_months:
one: "1 miesiąc"
few: "%{count} miesiące"
other: "%{count} miesięcy"
about_x_years:
one: "około rok"
few: "około %{count} lata"
other: "około %{count} lat"
over_x_years:
one: "ponad rok"
few: "ponad %{count} lata"
other: "ponad %{count} lat"
almost_x_years:
one: "prawie rok"
few: "prawie %{count} lata"
other: "prawie %{count} lat"
prompts:
year: "Rok"
month: "Miesiąc"
day: "Dzień"
hour: "Godzina"
minute: "Minuta"
second: "Sekundy"

helpers:
select:
prompt: "Proszę wybrać"

submit:
create: 'Utwórz %{model}'
update: 'Aktualizuj %{model}'
submit: 'Zapisz %{model}'

errors:
format: "%{attribute} %{message}"

messages: &errors_messages
inclusion: "nie znajduje się na liście dopuszczalnych wartości"
exclusion: "jest zarezerwowane"
invalid: "jest nieprawidłowe"
confirmation: "nie zgadza się z potwierdzeniem"
accepted: "musi zostać zaakceptowane"
empty: "nie może być puste"
blank: "nie może być puste"
too_long: "jest za długie (maksymalnie %{count} znaków)"
too_short: "jest za krótkie (przynajmniej %{count} znaków)"
wrong_length: "ma nieprawidłową długość (powinna wynosić %{count} znaków)"
not_a_number: "nie jest liczbą"
not_an_integer: "musi być liczbą całkowitą"
greater_than: "musi być większe od %{count}"
greater_than_or_equal_to: "musi być większe lub równe %{count}"
equal_to: "musi być równe %{count}"
less_than: "musi być mniejsze od %{count}"
less_than_or_equal_to: "musi być mniejsze lub równe %{count}"
odd: "musi być nieparzyste"
even: "musi być parzyste"

activerecord:
errors:
template:
header:
one: "%{model} nie został zachowany z powodu jednego błędu"
other: "%{model} nie został zachowany z powodu %{count} błędów"
body: "Błędy dotyczą następujących pól:"

messages:
taken: "zostało już zajęte"
record_invalid: "Negatywne sprawdzenie poprawności: %{errors}"
<<: *errors_messages

full_messages:
format: "%{attribute}%{message}"

0 comments on commit e135135

Please sign in to comment.