Skip to content

Commit

Permalink
lang: Introduce Qt specific plurals
Browse files Browse the repository at this point in the history
These were derived from CLDR back then, but they are not being updated.

See translate/translate#786
  • Loading branch information
nijel committed Dec 19, 2023
1 parent cb4c5bd commit 25c6601
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
4 changes: 4 additions & 0 deletions weblate/formats/ttkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,10 @@ class TSFormat(TTKitFormat):
unit_class = TSUnit
set_context_bilingual = False
supports_plural: bool = True
plural_preference = (
Plural.SOURCE_QT,
Plural.SOURCE_DEFAULT,
)


class XliffFormat(TTKitFormat):
Expand Down
33 changes: 33 additions & 0 deletions weblate/lang/migrations/0002_alter_plural_source.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright © Michal Čihař <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later

# Generated by Django 4.2.8 on 2023-12-19 11:51

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("lang", "0001_squashed_weblate_5"),
]

operations = [
migrations.AlterField(
model_name="plural",
name="source",
field=models.SmallIntegerField(
choices=[
(0, "Default plural"),
(1, "gettext plural formula"),
(3, "CLDR plural with zero"),
(4, "CLDR v38+ plural"),
(5, "Android plural"),
(6, "Qt Linguist plural"),
(2, "Manually entered formula"),
],
default=0,
verbose_name="Plural definition source",
),
),
]
5 changes: 4 additions & 1 deletion weblate/lang/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from django.utils.translation.trans_real import parse_accept_lang_header
from weblate_language_data.aliases import ALIASES
from weblate_language_data.countries import DEFAULT_LANGS
from weblate_language_data.plurals import CLDRPLURALS, EXTRAPLURALS
from weblate_language_data.plurals import CLDRPLURALS, EXTRAPLURALS, QTPLURALS
from weblate_language_data.rtl import RTL_LANGS

from weblate.checks.format import BaseFormatCheck
Expand Down Expand Up @@ -501,6 +501,7 @@ def setup(self, update, logger=lambda x: x):
extra_plurals = (
(Plural.SOURCE_GETTEXT, EXTRAPLURALS),
(Plural.SOURCE_CLDR, CLDRPLURALS),
(Plural.SOURCE_QT, QTPLURALS),
)
for source, definitions in extra_plurals:
for code, _unused, nplurals, plural_formula in definitions:
Expand Down Expand Up @@ -767,6 +768,7 @@ class Plural(models.Model):
SOURCE_CLDR_ZERO = 3
SOURCE_CLDR = 4
SOURCE_ANDROID = 5
SOURCE_QT = 6
source = models.SmallIntegerField(
default=SOURCE_DEFAULT,
verbose_name=gettext_lazy("Plural definition source"),
Expand All @@ -776,6 +778,7 @@ class Plural(models.Model):
(SOURCE_CLDR_ZERO, gettext_lazy("CLDR plural with zero")),
(SOURCE_CLDR, gettext_lazy("CLDR v38+ plural")),
(SOURCE_ANDROID, gettext_lazy("Android plural")),
(SOURCE_QT, gettext_lazy("Qt Linguist plural")),
(SOURCE_MANUAL, gettext_lazy("Manually entered formula")),
),
)
Expand Down

0 comments on commit 25c6601

Please sign in to comment.