Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
tashi-yangchen authored Oct 16, 2022
2 parents 81d8133 + cb31b41 commit f1ba59c
Show file tree
Hide file tree
Showing 127 changed files with 1,349 additions and 1,606 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on:
- push
- pull_request

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby-version:
- '2.7'
- '3.0'
- '3.1'

steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{ matrix.ruby-version }}"
bundler-cache: true
- run: bundle exec rake
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

43 changes: 43 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
## unreleased

- French (fr, fr-CA, fr-CH, fr-CA): change an abreviation for March month in abbr_month_names #1002

## 7.0.5 (2022-07-03)

- No changes.

## 7.0.4 (2022-07-03)

- Add following locales:
- Western Frisian (fy) #985
- Kazakh (kk) #945
- Update following locales:
- Slovak (sk): Fixed missing message #994
- French (fr): Revert remainder of NBSP characters #996
- French (fr): Use no-padded date format #991
- Arabic (ar): fix errors.messages.greater_than typo #998
- South slavic pluralizers #987
- Update update.rb to fetch active_model locale #1000
- Remove eager loading of translations during boot phase (this is now done by Rails). #983

## 7.0.3 (2022-03-01)

- Revert long date formats on default "en" locale #980

## 7.0.2 (2022-02-12)

- Fix long date format for many locales #939 #943
- Update following locales:
- Chinese (zh-TW) #941
- Croatian (hr) #940
- Danish (da) #802 #946 #947 #948
- Finnish (fi) #949
- French (fr) #968
- Galician (gl) #961
- Papiamento (pap-AW, pap-CW) #974 #975
- Serbian (sr) #972
- Spanish (es, es-CL, es-ES) #936
- Swedish (sv) #935
- Tamil (ta) #953
- Fix require statement in `rails/pluralization/tr` #964
- Add rails/ordinals to s.files in Gemspec #969
- Update i18n-tasks to be ActiveSupport 7+ ready #970

## 7.0.1 (2021-12-24)

- Fix ordinals loading.
Expand Down
60 changes: 30 additions & 30 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
PATH
remote: .
specs:
rails-i18n (7.0.1)
rails-i18n (7.0.5)
i18n (>= 0.7, < 2)
railties (>= 6.0.0, < 8)

GEM
remote: https://rubygems.org/
specs:
actionpack (7.0.0)
actionview (= 7.0.0)
activesupport (= 7.0.0)
actionpack (7.0.3.1)
actionview (= 7.0.3.1)
activesupport (= 7.0.3.1)
rack (~> 2.0, >= 2.2.0)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionview (7.0.0)
activesupport (= 7.0.0)
actionview (7.0.3.1)
activesupport (= 7.0.3.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activesupport (7.0.0)
activesupport (7.0.3.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
builder (3.2.4)
concurrent-ruby (1.1.9)
concurrent-ruby (1.1.10)
crass (1.0.6)
diff-lcs (1.4.4)
erubi (1.10.0)
diff-lcs (1.5.0)
erubi (1.11.0)
highline (2.0.3)
i18n (1.8.11)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
i18n-spec (0.6.0)
iso
Expand All @@ -49,34 +49,34 @@ GEM
terminal-table (>= 1.5.1)
iso (0.4.0)
i18n
loofah (2.13.0)
loofah (2.18.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
method_source (1.0.0)
mini_portile2 (2.6.1)
minitest (5.15.0)
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
mini_portile2 (2.8.0)
minitest (5.16.3)
nokogiri (1.13.8)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
parser (3.1.0.0)
parser (3.1.2.1)
ast (~> 2.4.1)
racc (1.6.0)
rack (2.2.3)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rack (2.2.4)
rack-test (2.0.2)
rack (>= 1.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.4.2)
rails-html-sanitizer (1.4.3)
loofah (~> 2.3)
railties (7.0.0)
actionpack (= 7.0.0)
activesupport (= 7.0.0)
railties (7.0.3.1)
actionpack (= 7.0.3.1)
activesupport (= 7.0.3.1)
method_source
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
rainbow (3.0.0)
rainbow (3.1.1)
rake (13.0.6)
rspec-core (3.9.3)
rspec-support (~> 3.9.3)
Expand All @@ -97,11 +97,11 @@ GEM
rspec-support (3.9.4)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
thor (1.1.0)
tzinfo (2.0.4)
thor (1.2.1)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
unicode-display_width (2.1.0)
zeitwerk (2.5.1)
unicode-display_width (2.2.0)
zeitwerk (2.6.0)

PLATFORMS
ruby
Expand All @@ -113,4 +113,4 @@ DEPENDENCIES
rspec-rails (~> 3.7)

BUNDLED WITH
2.2.31
2.3.7
64 changes: 50 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Rails Locale Data Repository
============================

[![Gem Version](https://badge.fury.io/rb/rails-i18n.svg)](http://badge.fury.io/rb/rails-i18n)
[![Build Status](https://secure.travis-ci.org/svenfuchs/rails-i18n.svg)](http://travis-ci.org/svenfuchs/rails-i18n)
[![CI](https://github.com/svenfuchs/rails-i18n/actions/workflows/ci.yml/badge.svg)](https://github.com/svenfuchs/rails-i18n/actions/workflows/ci.yml)

Centralization of locale data collection for Ruby on Rails.

Expand Down Expand Up @@ -35,6 +35,31 @@ Note that your Ruby on Rails version must be 3.0 or higher in order to install t

## Configuration

### Enabled modules

By default, all `rails-i18n` modules (locales, pluralization, transliteration, ordinals) are enabled.

If you would like to only enable specific modules, you can do so in your Rails configuration:

```ruby
# to enable only pluralization rules, but disable all other features
config.rails_i18n.enabled_modules = [:pluralization]

# to enable pluralization and ordinals
config.rails_i18n.enabled_modules = [:pluralization, :ordinals]
```

The possible module names:

* `:locale`
* `:ordinals`
* `:pluralization`
* `:transliteration`

Setting `enabled_modules` will restrict the gem's loaded features to only the specific types.

### Available locales

`rails-i18n` gem initially loads all available locale files, pluralization and transliteration rules. This default behaviour can be changed. If you specify in `config/environments/*` the locales which have to be loaded via `I18n.available_locales` option:

``` ruby
Expand All @@ -61,21 +86,33 @@ Locale data whose structure is compatible with Rails 2.3 are available on the se

## Available Locales

Available locales:
**Available locales:**


> af, ar, az, be, bg, bn, bs, ca, cs, cy, da, de, de-AT, de-CH, de-DE, dz, el, el-CY,
> en, en-AU, en-CA, en-GB, en-IE, en-IN, en-NZ, en-US, en-ZA, en-CY, en-TT, eo, es,
> es-419, es-AR, es-CL, es-CO, es-CR, es-EC, es-ES, es-MX, es-NI, es-PA, es-PE, es-US, es-VE,
> et, eu, fa, fi, fr, fr-CA, fr-CH, fr-FR, gl, he, hi, hi-IN, hr, hu, id, is, it,
> it-CH, ja, ka, km, kn, ko, lb, lo, lt, lv, mk, ml, mn, mr-IN, ms, nb, ne, nl, nn, oc, or,
> pa, pl, pt, pt-BR, rm, ro, ru, sk, sl, sq, sr, st, sw, ta, te, th, tl, tr, tt, ug,
> ur, uz, vi, wo, zh-CN, zh-HK, zh-TW, zh-YUE
af, ar, az, be, bg, bn, bs, ca, cs, csb, da, de, de-AT, de-CH, de-DE, dsb, dz, el, el-CY, en, en-AU, en-CA, en-CY, en-GB, en-IE, en-IN, en-NZ, en-TT, en-US, en-ZA, eo, es, es-419, es-AR, es-CL, es-CO, es-CR, es-EC, es-ES, es-MX, es-NI, es-PA, es-PE, es-US, es-VE, et, eu, fa, fi, fr, fr-CA, fr-CH, fr-FR, fur, fy, gl, gsw-CH, he, hi, hi-IN, hr, hsb, hu, id, is, it, it-CH, ja, ka, kk, km, kn, ko, lb, lo, lt, lv, mg, mk, ml, mn, mr-IN, ms, nb, ne, nl, nn, oc, or, pa, pap-AW, pap-CW, pl, pt, pt-BR, rm, ro, ru, sc, scr, sk, sl, sq, sr, st, sv, sv-SE, sw, ta, te, th, tl, tr, tt, ug, uk, ur, uz, vi, wo, zh-CN, zh-HK, zh-TW, zh-YUE

Complete locales:
**Complete locales:**

da, de, de-AT, de-CH, de-DE, en-US, es, es-419, es-AR, es-CL, es-CO, es-CR, es-EC, es-ES, es-MX, es-NI, es-PA, es-PE, es-US, es-VE, et, fa, fr, fr-CA, fr-CH, fr-FR, fy, id, it, ja, ka, ml, nb, nl, nn, pt, pt-BR, sv, sv-SE, tr, zh-CN, zh-HK, zh-TW, zh-YUE, uk

**Locales with missing pluralization rules**

af, csb, dsb, fur, gsw-CH, lb, rm, scr, sq, te, tt, ug, uz

**Removed locales:**

cy

The cy locale was removed in commit 84f6c6b9b7a3e50df2b1fb1ccf7add329f7eab4f since unfortunately we could not find a Welsh speaker to support it.
We would welcome contributions to add it back to the project.
The locale is mostly complete for the missing translations please refer to [#1006](https://github.com/svenfuchs/rails-i18n/issues/1006)

**Removed pluralizations:**

ak, am, bh, bm, bo, br, by, cy, dz, ff, ga, gd, guw, gv, ig, ii, iu, jv, kab, kde, kea, ksh, kw, lag, ln, mo, mt, my, naq, nso, root, sah, se, ses, sg, sh, shi, sma, smi, smj, smn, sms, ti, to, tzm, wa, yo, zh

The above pluralization rules were removed because they did not have corresponding locale files.

> af, da, de, de-AT, de-CH, de-DE, en-US, es, es-419, es-AR, es-CL, es-CO, es-CR, es-EC,
> es-ES, es-MX, es-NI, es-PA, es-PE, es-US, es-VE, et, fa, fr, fr-CA, fr-CH, fr-FR, id, it, ja, ka, ml, nb,
> nl, nn, pt, pt-BR, sv, sv-SE, tr, zh-CN, zh-HK, zh-TW, zh-YUE, uk

Currently, most locales are incomplete. Typically they lack the following keys:

Expand Down Expand Up @@ -219,7 +256,6 @@ To run the other commands described above:

```
docker run railsi18n bundle exec rake i18n-spec:completeness rails/locale/en.yml rails/locale/YOUR_NEW_LOCALE.yml
```

## See also
Expand Down
10 changes: 10 additions & 0 deletions lib/rails_i18n.rb
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
module RailsI18n
def self.enabled_modules
@enabled_modules ||= Set.new
end

def self.enabled_modules=(other)
@enabled_modules = Set.new(other)
end
end

require 'rails_i18n/railtie'
2 changes: 1 addition & 1 deletion lib/rails_i18n/common_pluralizations/east_slavic.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Originally was implemented by Yaroslav Markin in "russian" gem
# (http://github.com/yaroslav/russian)
#
# Used for Belarusian, Bosnian, Croatian, Russian, Serbo-Croatian, Ukrainian.
# Used for Belarusian, Russian, Ukrainian.

module RailsI18n
module Pluralization
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
module RailsI18n
module Pluralization
module Serbian
module OneFewOther
FROM_2_TO_4 = (2..4).to_a.freeze
FROM_12_TO_14 = (12..14).to_a.freeze

def self.rule
lambda do |n|
n ||= 0
frac = (n.to_d % 1)

if frac.nonzero?
n = frac.to_s.split('.').last.to_i
end

mod10 = n % 10
mod100 = n % 100

Expand All @@ -29,4 +35,4 @@ def self.with_locale(locale)
end
end
end
end
end
15 changes: 9 additions & 6 deletions lib/rails_i18n/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

module RailsI18n
class Railtie < ::Rails::Railtie #:nodoc:
initializer 'rails-i18n' do |app|
app.config.eager_load_namespaces << ::I18n if ::I18n.respond_to?(:eager_load!)
config.rails_i18n = RailsI18n

initializer 'rails-i18n' do |app|
RailsI18n::Railtie.instance_eval do
pattern = pattern_from app.config.i18n.available_locales

add("rails/locale/#{pattern}.yml")
add("rails/pluralization/#{pattern}.rb")
add("rails/ordinals/#{pattern}.rb")
add("rails/transliteration/#{pattern}.{rb,yml}")
if app.config.rails_i18n.enabled_modules.empty?
RailsI18n.enabled_modules = Set.new([:locale, :pluralization, :ordinals, :transliteration])
end

RailsI18n.enabled_modules.each do |feature|
add("rails/#{feature}/#{pattern}.{rb,yml}")
end

init_pluralization_module
end
Expand Down
Loading

0 comments on commit f1ba59c

Please sign in to comment.