From 3748a528c1ece056796ef0b8e830729cc547fc82 Mon Sep 17 00:00:00 2001 From: Tsutomu Kuroda Date: Fri, 5 Jul 2013 09:20:50 +0900 Subject: [PATCH] Prepare locales.thor for Rails 4.0.0 --- locales.thor | 16 +++ rails/rails3/active_support.yml | 76 ------------ rails/rails4/action_view.yml | 56 +++++++++ rails/{rails3 => rails4}/active_model.yml | 6 +- rails/{rails3 => rails4}/active_record.yml | 11 +- .../active_support.yml} | 109 +++++++----------- rails/test/lib/key_structure.rb | 2 +- 7 files changed, 130 insertions(+), 146 deletions(-) delete mode 100644 rails/rails3/active_support.yml create mode 100644 rails/rails4/action_view.yml rename rails/{rails3 => rails4}/active_model.yml (89%) rename rails/{rails3 => rails4}/active_record.yml (82%) rename rails/{rails3/action_view.yml => rails4/active_support.yml} (60%) diff --git a/locales.thor b/locales.thor index a5e65ed01..63ff622af 100644 --- a/locales.thor +++ b/locales.thor @@ -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 diff --git a/rails/rails3/active_support.yml b/rails/rails3/active_support.yml deleted file mode 100644 index 10333df29..000000000 --- a/rails/rails3/active_support.yml +++ /dev/null @@ -1,76 +0,0 @@ -"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 " diff --git a/rails/rails4/action_view.yml b/rails/rails4/action_view.yml new file mode 100644 index 000000000..baacf6e2c --- /dev/null +++ b/rails/rails4/action_view.yml @@ -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}' diff --git a/rails/rails3/active_model.yml b/rails/rails4/active_model.yml similarity index 89% rename from rails/rails3/active_model.yml rename to rails/rails4/active_model.yml index 146c9dda9..b622be1a9 100644 --- a/rails/rails3/active_model.yml +++ b/rails/rails4/active_model.yml @@ -1,4 +1,4 @@ -"default": +default: errors: # The default format to use in full error messages. format: "%{attribute} %{message}" @@ -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)" @@ -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" diff --git a/rails/rails3/active_record.yml b/rails/rails4/active_record.yml similarity index 82% rename from rails/rails3/active_record.yml rename to rails/rails4/active_record.yml index a402f830b..971eb4ded 100644 --- a/rails/rails3/active_record.yml +++ b/rails/rails4/active_record.yml @@ -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. diff --git a/rails/rails3/action_view.yml b/rails/rails4/active_support.yml similarity index 60% rename from rails/rails3/action_view.yml rename to rails/rails4/active_support.yml index a4ab78d11..9d266d6f5 100644 --- a/rails/rails3/action_view.yml +++ b/rails/rails4/active_support.yml @@ -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 @@ -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) @@ -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 @@ -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 @@ -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 @@ -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 @@ -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}' - diff --git a/rails/test/lib/key_structure.rb b/rails/test/lib/key_structure.rb index bc81dcca8..71132b7fb 100644 --- a/rails/test/lib/key_structure.rb +++ b/rails/test/lib/key_structure.rb @@ -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"