-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
16 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,30 @@ | ||
{% macro pluralize(language, number) %} | ||
{%- set key_prefix = "" -%} | ||
|
||
{# Arabic-specific pluralization rules #} | ||
{%- if language == "ar" -%} | ||
{# Arabic-specific pluralization rules #} | ||
{%- set modulo = number % 100 -%} | ||
{%- if number > 100 -%} | ||
{%- if modulo == 0 or modulo == 1 or modulo == 2 -%} | ||
{%- set key_prefix = "special_" -%} {# Sixth form for numbers above 100 ending with 0, 1, or 2 #} | ||
{%- endif -%} | ||
{%- elif number == 0 -%} | ||
{%- set key_prefix = "zero_" -%} {# First form for 0 #} | ||
{%- elif number == 1 -%} | ||
{%- set key_prefix = "one_" -%} {# Second form for 1 #} | ||
{%- elif number == 2 -%} | ||
{%- set key_prefix = "two_" -%} {# Third form for 2 #} | ||
{%- elif modulo >= 3 and modulo <= 10 -%} | ||
{%- set key_prefix = "few_" -%} {# Fourth form for numbers ending 3-10 #} | ||
{%- elif modulo >= 11 and modulo <= 99 -%} | ||
{%- set key_prefix = "many_" -%} {# Fifth form for numbers ending 11-99 #} | ||
|
||
{%- if number == 0 -%} | ||
{%- set key_prefix = "zero_" -%} | ||
{%- elif number == 1 %} | ||
{%- set key_prefix = "one_" -%} | ||
{%- elif number == 2 %} | ||
{%- set key_prefix = "two_" -%} | ||
{%- elif number >= 3 and number <= 10 or modulo >= 3 and modulo <= 10 %} | ||
{%- set key_prefix = "few_" -%} | ||
{%- else -%} | ||
{%- set key_prefix = "other_" -%} {# Catch-all for any other cases #} | ||
{%- set key_prefix = "many_" -%} | ||
{%- endif -%} | ||
|
||
{# Other languages #} | ||
{%- else -%} | ||
{# Default pluralization logic for languages other than Arabic #} | ||
{%- if number == 1 -%} | ||
{%- set key_prefix = "one_" -%} | ||
{%- else -%} | ||
{%- set key_prefix = "many_" -%} | ||
{%- endif -%} | ||
{%- endif -%} | ||
{{- key_prefix -}} | ||
|
||
{{-key_prefix-}} | ||
{% endmacro %} |