Skip to content

Commit

Permalink
Prepare locales.thor for Rails 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kuroda committed Jul 5, 2013
1 parent df05d41 commit 3748a52
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 146 deletions.
16 changes: 16 additions & 0 deletions locales.thor
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,20 @@ class Locales < Thor
end
puts locales.sort.join(', ')
end

desc 'incomplete', 'List incomplete locales'
def incomplete
locales = []
Dir.glob(File.dirname(__FILE__) + '/rails/locale/*.{rb,yml}') do |filename|
if md = filename.match(/([\w\-]+)\.(rb|yml)$/)
locale = md[1]

missing_keys, broken_keys, missing_pluralizations = KeyStructure.check(locale)
unless missing_keys.empty? && broken_keys.empty? && missing_pluralizations.empty?
locales << locale
end
end
end
puts locales.sort.join(', ')
end
end
76 changes: 0 additions & 76 deletions rails/rails3/active_support.yml

This file was deleted.

56 changes: 56 additions & 0 deletions rails/rails4/action_view.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"default":
# Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
datetime:
distance_in_words:
half_a_minute: "half a minute"
less_than_x_seconds:
one: "less than 1 second"
other: "less than %{count} seconds"
x_seconds:
one: "1 second"
other: "%{count} seconds"
less_than_x_minutes:
one: "less than a minute"
other: "less than %{count} minutes"
x_minutes:
one: "1 minute"
other: "%{count} minutes"
about_x_hours:
one: "about 1 hour"
other: "about %{count} hours"
x_days:
one: "1 day"
other: "%{count} days"
about_x_months:
one: "about 1 month"
other: "about %{count} months"
x_months:
one: "1 month"
other: "%{count} months"
about_x_years:
one: "about 1 year"
other: "about %{count} years"
over_x_years:
one: "over 1 year"
other: "over %{count} years"
almost_x_years:
one: "almost 1 year"
other: "almost %{count} years"
prompts:
year: "Year"
month: "Month"
day: "Day"
hour: "Hour"
minute: "Minute"
second: "Seconds"

helpers:
select:
# Default value for :prompt => true in FormOptionsHelper
prompt: "Please select"

# Default translation keys for submit and button FormHelper
submit:
create: 'Create %{model}'
update: 'Update %{model}'
submit: 'Save %{model}'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"default":
default:
errors:
# The default format to use in full error messages.
format: "%{attribute} %{message}"
Expand All @@ -9,10 +9,11 @@
inclusion: "is not included in the list"
exclusion: "is reserved"
invalid: "is invalid"
confirmation: "doesn't match confirmation"
confirmation: "doesn't match %{attribute}"
accepted: "must be accepted"
empty: "can't be empty"
blank: "can't be blank"
present: "must be blank"
too_long: "is too long (maximum is %{count} characters)"
too_short: "is too short (minimum is %{count} characters)"
wrong_length: "is the wrong length (should be %{count} characters)"
Expand All @@ -23,5 +24,6 @@
equal_to: "must be equal to %{count}"
less_than: "must be less than %{count}"
less_than_or_equal_to: "must be less than or equal to %{count}"
other_than: "must be other than %{count}"
odd: "must be odd"
even: "must be even"
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
"default":
default:
# Attributes names common to most models
#attributes:
#created_at: "Created at"
#updated_at: "Updated at"

# Default error messages
errors:
messages:
taken: "has already been taken"

# Active Record models configuration
activerecord:
errors:
messages:
taken: "has already been taken"
record_invalid: "Validation failed: %{errors}"
restrict_dependent_destroy:
one: "Cannot delete record because a dependent %{record} exists"
many: "Cannot delete record because dependent %{record} exist"
# Append your own errors here or at the model/attributes scope.

# You can define own errors for models or model attributes.
Expand Down
109 changes: 44 additions & 65 deletions rails/rails3/action_view.yml → rails/rails4/active_support.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
"default":
default:
date:
formats:
# Use the strftime parameters for formats.
# When no format has been given, it uses default.
# You can provide other formats here if you like!
default: "%Y-%m-%d"
short: "%b %d"
long: "%B %d, %Y"

day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]
abbr_day_names: [Sun, Mon, Tue, Wed, Thu, Fri, Sat]

# Don't forget the nil at the beginning; there's no such thing as a 0th month
month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December]
abbr_month_names: [~, Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec]
# Used in date_select and datetime_select.
order:
- year
- month
- day

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

# Used in array.to_sentence.
support:
array:
words_connector: ", "
two_words_connector: " and "
last_word_connector: ", and "
number:
# Used in number_with_delimiter()
# Used in NumberHelper.number_to_delimited()
# These are also the defaults for 'currency', 'percentage', 'precision', and 'human'
format:
# Sets the separator between the units, for more precision (e.g. 1.0 / 2.0 == 0.5)
separator: "."
# Delimets thousands (e.g. 1,000,000 is a million) (always in groups of three)
# Delimits thousands (e.g. 1,000,000 is a million) (always in groups of three)
delimiter: ","
# Number of decimals, behind the separator (the number 1 with a precision of 2 gives: 1.00)
precision: 3
Expand All @@ -15,7 +50,7 @@
# If set, the zeros after the decimal separator will always be stripped (eg.: 1.200 will be 1.2)
strip_insignificant_zeros: false

# Used in number_to_currency()
# Used in NumberHelper.number_to_currency()
currency:
format:
# Where is the currency sign? %u is the currency unit, %n the number (default: $5.00)
Expand All @@ -28,7 +63,7 @@
significant: false
strip_insignificant_zeros: false

# Used in number_to_percentage()
# Used in NumberHelper.number_to_percentage()
percentage:
format:
# These five are to override number.format and are optional
Expand All @@ -37,8 +72,9 @@
# precision:
# significant: false
# strip_insignificant_zeros: false
format: "%n%"

# Used in number_to_precision()
# Used in NumberHelper.number_to_rounded()
precision:
format:
# These five are to override number.format and are optional
Expand All @@ -48,7 +84,7 @@
# significant: false
# strip_insignificant_zeros: false

# Used in number_to_human_size() and number_to_human()
# Used in NumberHelper.number_to_human_size() and NumberHelper.number_to_human()
human:
format:
# These five are to override number.format and are optional
Expand All @@ -70,7 +106,7 @@
mb: "MB"
gb: "GB"
tb: "TB"
# Used in number_to_human()
# Used in NumberHelper.number_to_human()
decimal_units:
format: "%n %u"
# Decimal units output formatting
Expand All @@ -95,60 +131,3 @@
billion: Billion
trillion: Trillion
quadrillion: Quadrillion

# Used in distance_of_time_in_words(), distance_of_time_in_words_to_now(), time_ago_in_words()
datetime:
distance_in_words:
half_a_minute: "half a minute"
less_than_x_seconds:
one: "less than 1 second"
other: "less than %{count} seconds"
x_seconds:
one: "1 second"
other: "%{count} seconds"
less_than_x_minutes:
one: "less than a minute"
other: "less than %{count} minutes"
x_minutes:
one: "1 minute"
other: "%{count} minutes"
about_x_hours:
one: "about 1 hour"
other: "about %{count} hours"
x_days:
one: "1 day"
other: "%{count} days"
about_x_months:
one: "about 1 month"
other: "about %{count} months"
x_months:
one: "1 month"
other: "%{count} months"
about_x_years:
one: "about 1 year"
other: "about %{count} years"
over_x_years:
one: "over 1 year"
other: "over %{count} years"
almost_x_years:
one: "almost 1 year"
other: "almost %{count} years"
prompts:
year: "Year"
month: "Month"
day: "Day"
hour: "Hour"
minute: "Minute"
second: "Seconds"

helpers:
select:
# Default value for :prompt => true in FormOptionsHelper
prompt: "Please select"

# Default translation keys for submit FormHelper
submit:
create: 'Create %{model}'
update: 'Update %{model}'
submit: 'Save %{model}'

2 changes: 1 addition & 1 deletion rails/test/lib/key_structure.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def init_backend(locale)
I18n.load_path = []
I18n.reload!

I18n.load_path += Dir[File.dirname(__FILE__) + "/../../rails3/*.yml"]
I18n.load_path += Dir[File.dirname(__FILE__) + "/../../rails4/*.yml"]

path = File.dirname(__FILE__) + "/../../locale/#{locale}.rb"

Expand Down

0 comments on commit 3748a52

Please sign in to comment.