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

Add plurals dropped from rails-i18n in 7.0.6 #266

Merged
merged 1 commit into from
Nov 21, 2022
Merged
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: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Unreleased

- Add I18n plural rules for Welsh (cy), Maltese (mt) and Chinese (zh) since Rails-I18n has [dropped support](https://github.com/svenfuchs/rails-i18n/pull/1017) for them in 7.0.6 ([#266](https://github.com/alphagov/govuk_app_config/pull/266))

# 4.10.1

- Fix an object ownership/sharing bug where the Rails log level was erroneously being set to `WARN` when initialising Sentry.
Expand Down
32 changes: 32 additions & 0 deletions lib/govuk_app_config/govuk_i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ def self.plurals
{
# Azerbaijani
az: { i18n: { plural: { keys: %i[one other], rule: ->(n) { n == 1 ? :one : :other } } } },
# Welsh
cy: { i18n: { plural: { keys: %i[zero one two few many other],
rule:
lambda do |n|
case n
when 0 then :zero
when 1 then :one
when 2 then :two
when 3 then :few
when 6 then :many
else :other
end
end } } },
# Dari - this isn't an iso code. Probably should be 'prs' as per ISO 639-3.
dr: { i18n: { plural: { keys: %i[one other], rule: ->(n) { n == 1 ? :one : :other } } } },
# Latin America and Caribbean Spanish
Expand Down Expand Up @@ -31,12 +44,31 @@ def self.plurals
kk: { i18n: { plural: { keys: %i[one other], rule: ->(n) { n == 1 ? :one : :other } } } },
# Punjabi Shahmukhi
"pa-pk": { i18n: { plural: { keys: %i[one other], rule: ->(n) { n == 1 ? :one : :other } } } },
# Maltese
mt: { i18n: { plural: { keys: %i[one few many other],
rule:
lambda do |n|
n ||= 0
mod100 = n % 100

if n == 1
:one
elsif n.zero? || (2..10).to_a.include?(mod100)
:few
elsif (11..19).to_a.include?(mod100)
:many
else
:other
end
end } } },
# Sinhalese
si: { i18n: { plural: { keys: %i[one other], rule: ->(n) { n == 1 ? :one : :other } } } },
# Turkish
tr: { i18n: { plural: { keys: %i[one other], rule: ->(n) { n == 1 ? :one : :other } } } },
# Uzbek
uz: { i18n: { plural: { keys: %i[one other], rule: ->(n) { n == 1 ? :one : :other } } } },
# Chinese
zh: { i18n: { plural: { keys: %i[other], rule: ->(_) { :other } } } },
# Chinese Hong Kong
"zh-hk" => { i18n: { plural: { keys: %i[one other], rule: ->(n) { n == 1 ? :one : :other } } } },
# Chinese Taiwan
Expand Down