Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove trailing spaces #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.textile
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ I18n.locale = :ru

После загрузки Russian можно использовать все стандартные функции библиотеки I18n, пользоваться измененным функционалом для лучшей поддержки русского языка, или использовать хелперы модуля Russian для еще более простой работы с русским языком.

"Документация I18n":http://rdoc.info/github/svenfuchs/i18n/master
"Документация I18n":http://rdoc.info/github/svenfuchs/i18n/master

"Гид по интернационализации Ruby on Rails":http://guides.rubyonrails.org/i18n.html.

Expand Down Expand Up @@ -166,7 +166,7 @@ h3. Валидация
@Соглашение об использовании нужно принять соглашение@

если вы указали перевод для имени атрибута.

Но

@validates_acceptance_of :accepted_terms, :message => '^Нужно принять соглашение'@
Expand Down
22 changes: 11 additions & 11 deletions lib/russian.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- encoding: utf-8 -*-

$KCODE = 'u' if RUBY_VERSION < "1.9"

Expand All @@ -9,9 +9,9 @@

module Russian
extend self

autoload :Transliteration, 'transliteration'

# Russian locale
LOCALE = :'ru'

Expand All @@ -25,7 +25,7 @@ def locale
LOCALIZE_MONTH_NAMES_MATCH = /(%[-\d]?d|%e)(.*)(%B)/
LOCALIZE_STANDALONE_ABBR_DAY_NAMES_MATCH = /^%a/
LOCALIZE_STANDALONE_DAY_NAMES_MATCH = /^%A/

# Init Russian i18n: load all translations shipped with library.
def init_i18n
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)
Expand All @@ -39,23 +39,23 @@ def init_i18n
# See I18n::translate
def translate(key, options = {})
I18n.translate(key, options.merge({ :locale => LOCALE }))
end
end
alias :t :translate

# See I18n::localize
def localize(object, options = {})
I18n.localize(object, options.merge({ :locale => LOCALE }))
end
alias :l :localize

# strftime() proxy with Russian localization
def strftime(object, format = :default)
localize(object, { :format => format })
end

# Simple pluralization proxy
#
# Usage:
# Usage:
# Russian.pluralize(1, "вещь", "вещи", "вещей")
# Russian.pluralize(3.14, "вещь", "вещи", "вещей", "вещи")
def pluralize(n, *variants)
Expand All @@ -76,13 +76,13 @@ def transliterate(str)
Russian::Transliteration.transliterate(str)
end
alias :translit :transliterate

protected
# Returns all locale files shipped with library
def locale_files
Dir[File.join(File.dirname(__FILE__), "russian", "locale", "**/*")]
end

# Converts an array of pluralization variants to a Hash that can be used
# with I18n pluralization.
def pluralization_variants_to_hash(*variants)
Expand Down
20 changes: 10 additions & 10 deletions lib/russian/action_view_ext/helpers/date_helper.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# -*- encoding: utf-8 -*-
# -*- encoding: utf-8 -*-

# Заменяет хелпер Rails <tt>select_month</tt> и метод <tt>translated_month_names</tt>
# Заменяет хелпер Rails <tt>select_month</tt> и метод <tt>translated_month_names</tt>
# для поддержки функционала "отдельностоящих имен месяцев".
#
# Теперь можно использовать и полные, и сокращенные название месяцев в двух вариантах -- контекстном
# (по умолчанию) и отдельностоящем (если в текущем языке есть соответствующие переводы).
# Теперь хелперы поддерживают ключ <tt>:use_standalone_month_names</tt>, хелпер <tt>select_month</tt>
# Теперь хелперы поддерживают ключ <tt>:use_standalone_month_names</tt>, хелпер <tt>select_month</tt>
# устанавливает его по умолчанию.
# Отдельностоящие имена месяцев также используютс когда указан ключ <tt>:discard_day</tt>.
#
#
# Replaces Rails <tt>select_month</tt> helper and <tt>translated_month_names</tt> private method to provide
# "standalone month names" feature.
# "standalone month names" feature.
#
# It is now possible to use both abbreviated and full month names in two variants (if current locale provides them).
# All date helpers support <tt>:use_standalone_month_names</tt> key now, <tt>select_month</tt> helper sets
# All date helpers support <tt>:use_standalone_month_names</tt> key now, <tt>select_month</tt> helper sets
# it to true by default.
# Standalone month names are also used when <tt>:discard_day</tt> key is provided.
if defined?(ActionView::Helpers::DateTimeSelector)
Expand All @@ -27,7 +27,7 @@ module DateHelper
# instead of names -- set the <tt>:use_month_numbers</tt> key in +options+ to true for this to happen. If you
# want both numbers and names, set the <tt>:add_month_numbers</tt> key in +options+ to true. If you would prefer
# to show month names as abbreviations, set the <tt>:use_short_month</tt> key in +options+ to true. If you want
# to use your own month names, set the <tt>:use_month_names</tt> key in +options+ to an array of 12 month names.
# to use your own month names, set the <tt>:use_month_names</tt> key in +options+ to an array of 12 month names.
# You can also choose if you want to use i18n standalone month names or default month names -- you can
# force standalone month names usage by using <tt>:use_standalone_month_names</tt> key.
# Override the field name using the <tt>:field_name</tt> option, 'month' by default.
Expand Down Expand Up @@ -66,7 +66,7 @@ def select_month(date, options = {}, html_options = {})
DateTimeSelector.new(date, options.merge(:use_standalone_month_names => true), html_options).select_month
end
end

class DateTimeSelector #:nodoc:
private
# Returns translated month names
Expand Down Expand Up @@ -108,11 +108,11 @@ def translated_month_names
key = :'date.month_names'
end
end

I18n.translate(key, :locale => @options[:locale])
end

end
end
end
end # if defined?
end # if defined?
16 changes: 8 additions & 8 deletions lib/russian/active_model_ext/custom_error_message.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- encoding: utf-8 -*-

if defined?(ActiveModel::Errors)
module ActiveModel
Expand All @@ -13,19 +13,19 @@ class Errors
# теперь не имеют префикса с названием атрибута если в сообщении об ошибке первым символом указан "^".
#
# Так, например,
#
#
# validates_acceptance_of :accepted_terms, :message => 'нужно принять соглашение'
#
#
# даст сообщение
#
#
# Accepted terms нужно принять соглашение
#
#
# однако,
#
#
# validates_acceptance_of :accepted_terms, :message => '^Нужно принять соглашение'
#
#
# даст сообщение
#
#
# Нужно принять соглашение
#
#
Expand Down
16 changes: 8 additions & 8 deletions lib/russian/locale/actionview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ ru:
precision: 3
significant: false
strip_insignificant_zeros: false

# Used in number_to_currency()
currency:
format:
Expand All @@ -30,35 +30,35 @@ ru:
precision: 2
significant: false
strip_insignificant_zeros: false

# Used in number_to_percentage()
percentage:
format:
# These three are to override number.format and are optional
# separator:
# separator:
delimiter: ""

# Used in number_to_precision()
precision:
format:
# These three are to override number.format and are optional
# separator:
delimiter: ""
# precision:

# Used in number_to_human_size()
human:
format:
# These three are to override number.format and are optional
# separator:
# separator:
delimiter: ""
precision: 1
significant: false
strip_insignificant_zeros: false

# Rails 2.2
# storage_units: [байт, КБ, МБ, ГБ, ТБ]

# Rails 2.3+
storage_units:
# Storage units output formatting.
Expand Down
2 changes: 1 addition & 1 deletion lib/russian/locale/activemodel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ru:
odd: "может иметь лишь четное значение"
even: "может иметь лишь нечетное значение"
record_invalid: "Возникли ошибки: %{errors}"

template:
# Заголовок сообщения об ошибке
header:
Expand Down
5 changes: 2 additions & 3 deletions lib/russian/locale/activerecord.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ru:
# The values :model, :attribute and :value are always available for interpolation
# The value :count is available when applicable. Can be used for pluralization.
#
# You can use ^-prefixed messages as well to get rid of human attribute name appearing
# You can use ^-prefixed messages as well to get rid of human attribute name appearing
# before your message in validation messages.
messages:
inclusion: "имеет непредусмотренное значение"
Expand Down Expand Up @@ -82,7 +82,7 @@ ru:
#
#
# Overrides default messages

# Перевод названий атрибутов моделей. Используется в Model.human_attribute_name(attribute).
#attributes:
# Например,
Expand All @@ -92,4 +92,3 @@ ru:
#
#
# Overrides model and default messages.

7 changes: 3 additions & 4 deletions lib/russian/locale/activesupport.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
ru:
# Используется в array.to_sentence
#
#
#
#
# Used in array.to_sentence.
support:
array:
# Rails 2.2
sentence_connector: "и"
skip_last_comma: true

# Rails 2.3
words_connector: ", "
two_words_connector: " и "
last_word_connector: " и "

2 changes: 1 addition & 1 deletion lib/russian/locale/datetime.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- encoding: utf-8 -*-

# Context-based month name and day name switching for Russian
#
Expand Down
10 changes: 5 additions & 5 deletions lib/russian/locale/datetime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ru:
default: "%d.%m.%Y"
short: "%d %b"
long: "%d %B %Y"

# Названия дней недели -- контекстные и отдельностоящие
common_day_names: [воскресенье, понедельник, вторник, среда, четверг, пятница, суббота]
standalone_day_names: [Воскресенье, Понедельник, Вторник, Среда, Четверг, Пятница, Суббота]
Expand All @@ -21,19 +21,19 @@ ru:

# Названия месяцев -- сокращенные и полные, плюс отдельностоящие.
# Не забудьте nil в начале массиве (~)
#
#
#
# Don't forget the nil at the beginning; there's no such thing as a 0th month
common_month_names: [~, января, февраля, марта, апреля, мая, июня, июля, августа, сентября, октября, ноября, декабря]
standalone_month_names: [~, Январь, Февраль, Март, Апрель, Май, Июнь, Июль, Август, Сентябрь, Октябрь, Ноябрь, Декабрь]
common_abbr_month_names: [~, янв., февр., марта, апр., мая, июня, июля, авг., сент., окт., нояб., дек.]
standalone_abbr_month_names: [~, янв., февр., март, апр., май, июнь, июль, авг., сент., окт., нояб., дек.]

# Порядок компонентов даты для хелперов
#
#
# Used in date_select and datime_select.
order:
order:
- :day
- :month
- :year
Expand All @@ -44,7 +44,7 @@ ru:
default: "%a, %d %b %Y, %H:%M:%S %z"
short: "%d %b, %H:%M"
long: "%d %B %Y, %H:%M"

# am/pm решено перевести как "утра/вечера" :)
am: "утра"
pm: "вечера"
8 changes: 4 additions & 4 deletions lib/russian/locale/pluralization.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- encoding: utf-8 -*-

# Правило плюрализации для русского языка, взято из CLDR, http://unicode.org/cldr/
#
Expand All @@ -19,10 +19,10 @@
:ru => {
:'i18n' => {
:plural => {
:rule => lambda { |n|
n % 10 == 1 && n % 100 != 11 ? :one : [2, 3, 4].include?(n % 10) && ![12, 13, 14].include?(n % 100) ? :few : n % 10 == 0 || [5, 6, 7, 8, 9].include?(n % 10) || [11, 12, 13, 14].include?(n % 100) ? :many : :other
:rule => lambda { |n|
n % 10 == 1 && n % 100 != 11 ? :one : [2, 3, 4].include?(n % 10) && ![12, 13, 14].include?(n % 100) ? :few : n % 10 == 0 || [5, 6, 7, 8, 9].include?(n % 10) || [11, 12, 13, 14].include?(n % 100) ? :many : :other
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion lib/russian/locale/transliterator.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- encoding: utf-8 -*-

# I18n transliteration delegates to Russian::Transliteration (we're unable
# to use common I18n transliteration tables with Russian)
Expand Down
2 changes: 1 addition & 1 deletion lib/russian/russian_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
end

if defined?(ActionView::Helpers)
require 'action_view_ext/helpers/date_helper'
require 'action_view_ext/helpers/date_helper'
end
6 changes: 3 additions & 3 deletions lib/russian/transliteration.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
# -*- encoding: utf-8 -*-

module Russian
# Russian transliteration
# Russian transliteration
#
# Транслитерация для букв русского алфавита
module Transliteration
Expand Down Expand Up @@ -69,4 +69,4 @@ def transliterate(str)
result
end
end
end
end
2 changes: 1 addition & 1 deletion spec/i18n/locale/datetime_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
# -*- encoding: utf-8 -*-

require File.dirname(__FILE__) + '/../../spec_helper'

Expand Down
Loading