Skip to content

Commit

Permalink
Adds plural rules not available in i18n
Browse files Browse the repository at this point in the history
We have these rules in four different apps so moving them to one place
to make it easier to maintain.
  • Loading branch information
MuriloDalRi committed Mar 18, 2021
1 parent b911c5b commit 80e1c12
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/govuk_app_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require "govuk_app_config/govuk_error"
require "govuk_app_config/govuk_error/configure"
require "govuk_app_config/govuk_healthcheck"
require "govuk_app_config/govuk_i18n"
# This require is deprecated and should be removed on next major version bump
# and should be required by applications directly.
require "govuk_app_config/govuk_unicorn"
Expand Down
38 changes: 38 additions & 0 deletions lib/govuk_app_config/govuk_i18n.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module GovukI18n
def plurals
{
# 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
"es-419": { i18n: { plural: { keys: %i[one other], rule: ->(n) { n == 1 ? :one : :other } } } },
# Scottish Gaelic
gd: { i18n: { plural: { keys: %i[one two few other],
rule:
lambda do |n|
if [1, 11].include?(n)
:one
elsif [2, 12].include?(n)
:two
elsif [3, 4, 5, 6, 7, 8, 9, 10, 13, 14, 15, 16, 17, 18, 19].include?(n)
:few
else
:other
end
end } } },
# Armenian
hy: { i18n: { plural: { keys: %i[one other], rule: ->(n) { n == 1 ? :one : :other } } } },
# Kazakh
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 } } } },
# Sinhalese
si: { 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 Hong Kong
"zh-hk" => { i18n: { plural: { keys: %i[one other], rule: ->(n) { n == 1 ? :one : :other } } } },
# Chinese Taiwan
"zh-tw" => { i18n: { plural: { keys: %i[one other], rule: ->(n) { n == 1 ? :one : :other } } } },
}
end
end

0 comments on commit 80e1c12

Please sign in to comment.