mirror of
https://github.com/welpo/tabi.git
synced 2026-02-15 23:57:19 +01:00
pluralize slavic languages
This commit is contained in:
parent
9f51ef591d
commit
3fe4ca5292
1 changed files with 18 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
{% macro translate(key, number=-1, language_strings="", default="") %}
|
||||
{%- set key_prefix = "" -%}
|
||||
{%- set slavic_plural_languages = ["uk", "be", "bs", "hr", "ru", "sr"] -%}
|
||||
|
||||
{%- set key_prefix = "" -%}
|
||||
{#- `zero_` and `one_` are common cases. We handle "many" (plural) later, after language-specific pluralization -#}
|
||||
{%- if number == 0 -%}
|
||||
{%- set key_prefix = "zero_" -%}
|
||||
|
|
@ -10,6 +11,7 @@
|
|||
|
||||
{#- Pluralization -#}
|
||||
{%- if number != -1 and key_prefix == "" -%}
|
||||
{#- Arabic -#}
|
||||
{%- if lang == "ar" -%}
|
||||
{%- set modulo = number % 100 -%}
|
||||
{%- if number == 2 -%}
|
||||
|
|
@ -19,6 +21,21 @@
|
|||
{%- else -%}
|
||||
{%- set key_prefix = "many_" -%}
|
||||
{%- endif -%}
|
||||
{#- Slavic languages like Russian or Ukrainian -#}
|
||||
{%- elif lang in slavic_plural_languages -%}
|
||||
{%- set modulo10 = number % 10 -%}
|
||||
{%- set modulo100 = number % 100 -%}
|
||||
{%- if modulo10 == 1 and modulo100 != 11 -%}
|
||||
{%- set key_prefix = "one_" -%}
|
||||
{%- elif modulo10 >= 2 and modulo10 <= 4 and not modulo100 >= 12 and not modulo100 <= 14 -%}
|
||||
{%- if modulo100 < 12 or modulo100 > 14 -%}
|
||||
{%- set key_prefix = "few_" -%}
|
||||
{%- else -%}
|
||||
{%- set key_prefix = "many_" -%}
|
||||
{%- endif -%}
|
||||
{%- else -%}
|
||||
{%- set key_prefix = "many_" -%}
|
||||
{%- endif -%}
|
||||
{%- else -%}
|
||||
{#- Default pluralization -#}
|
||||
{#- Zero and one are already handled -#}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue