add cyrillic plural forms support

This commit is contained in:
ghost 2023-10-16 02:30:55 +03:00
parent 3005b16c94
commit 453d70b7cb
15 changed files with 383 additions and 16 deletions

View File

@ -77,21 +77,42 @@ class AppExtension extends AbstractExtension
$values = $values =
[ [
365 * 24 * 60 * 60 => $this->translator->trans('year ago'), 365 * 24 * 60 * 60 =>
30 * 24 * 60 * 60 => $this->translator->trans('month ago'), [
24 * 60 * 60 => $this->translator->trans('day ago'), $this->translator->trans('year ago'),
60 * 60 => $this->translator->trans('hour ago'), $this->translator->trans('years ago'),
60 => $this->translator->trans('minute ago'), $this->translator->trans(' years ago')
1 => $this->translator->trans('second ago') ],
]; 30 * 24 * 60 * 60 =>
[
$plural = [ $this->translator->trans('month ago'),
$this->translator->trans('year ago') => $this->translator->trans('years ago'), $this->translator->trans('months ago'),
$this->translator->trans('month ago') => $this->translator->trans('months ago'), $this->translator->trans(' months ago')
$this->translator->trans('day ago') => $this->translator->trans('days ago'), ],
$this->translator->trans('hour ago') => $this->translator->trans('hours ago'), 24 * 60 * 60 =>
$this->translator->trans('minute ago') => $this->translator->trans('minutes ago'), [
$this->translator->trans('second ago') => $this->translator->trans('seconds ago') $this->translator->trans('day ago'),
$this->translator->trans('days ago'),
$this->translator->trans(' days ago')
],
60 * 60 =>
[
$this->translator->trans('hour ago'),
$this->translator->trans('hours ago'),
$this->translator->trans(' hours ago')
],
60 =>
[
$this->translator->trans('minute ago'),
$this->translator->trans('minutes ago'),
$this->translator->trans(' minutes ago')
],
1 =>
[
$this->translator->trans('second ago'),
$this->translator->trans('seconds ago'),
$this->translator->trans(' seconds ago')
]
]; ];
foreach ($values as $key => $value) foreach ($values as $key => $value)
@ -105,9 +126,19 @@ class AppExtension extends AbstractExtension
return sprintf( return sprintf(
'%s %s', '%s %s',
$round, $round,
$round > 1 ? $plural[$value] : $value $this->plural(
$round,
$value
)
); );
} }
} }
} }
private function plural(int $number, array $texts)
{
$cases = [2, 0, 1, 1, 1, 2];
return $texts[(($number % 100) > 4 && ($number % 100) < 20) ? 2 : $cases[min($number % 10, 5)]];
}
} }

View File

@ -693,6 +693,30 @@
<source>seconds ago</source> <source>seconds ago</source>
<target>seconds ago</target> <target>seconds ago</target>
</trans-unit> </trans-unit>
<trans-unit id="KGg3UPj" resname=" years ago">
<source> years ago</source>
<target> years ago</target>
</trans-unit>
<trans-unit id="LJz20sI" resname=" months ago">
<source> months ago</source>
<target> months ago</target>
</trans-unit>
<trans-unit id="r7fyHp0" resname=" days ago">
<source> days ago</source>
<target> days ago</target>
</trans-unit>
<trans-unit id="mga12oW" resname=" hours ago">
<source> hours ago</source>
<target> hours ago</target>
</trans-unit>
<trans-unit id="BAlvYYB" resname=" minutes ago">
<source> minutes ago</source>
<target> minutes ago</target>
</trans-unit>
<trans-unit id="m4YrK9n" resname=" seconds ago">
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@ -693,6 +693,30 @@
<source>seconds ago</source> <source>seconds ago</source>
<target>seconds ago</target> <target>seconds ago</target>
</trans-unit> </trans-unit>
<trans-unit id="KGg3UPj" resname=" years ago">
<source> years ago</source>
<target> years ago</target>
</trans-unit>
<trans-unit id="LJz20sI" resname=" months ago">
<source> months ago</source>
<target> months ago</target>
</trans-unit>
<trans-unit id="r7fyHp0" resname=" days ago">
<source> days ago</source>
<target> days ago</target>
</trans-unit>
<trans-unit id="mga12oW" resname=" hours ago">
<source> hours ago</source>
<target> hours ago</target>
</trans-unit>
<trans-unit id="BAlvYYB" resname=" minutes ago">
<source> minutes ago</source>
<target> minutes ago</target>
</trans-unit>
<trans-unit id="m4YrK9n" resname=" seconds ago">
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@ -693,6 +693,30 @@
<source>seconds ago</source> <source>seconds ago</source>
<target>seconds ago</target> <target>seconds ago</target>
</trans-unit> </trans-unit>
<trans-unit id="KGg3UPj" resname=" years ago">
<source> years ago</source>
<target> years ago</target>
</trans-unit>
<trans-unit id="LJz20sI" resname=" months ago">
<source> months ago</source>
<target> months ago</target>
</trans-unit>
<trans-unit id="r7fyHp0" resname=" days ago">
<source> days ago</source>
<target> days ago</target>
</trans-unit>
<trans-unit id="mga12oW" resname=" hours ago">
<source> hours ago</source>
<target> hours ago</target>
</trans-unit>
<trans-unit id="BAlvYYB" resname=" minutes ago">
<source> minutes ago</source>
<target> minutes ago</target>
</trans-unit>
<trans-unit id="m4YrK9n" resname=" seconds ago">
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@ -693,6 +693,30 @@
<source>seconds ago</source> <source>seconds ago</source>
<target>seconds ago</target> <target>seconds ago</target>
</trans-unit> </trans-unit>
<trans-unit id="KGg3UPj" resname=" years ago">
<source> years ago</source>
<target> years ago</target>
</trans-unit>
<trans-unit id="LJz20sI" resname=" months ago">
<source> months ago</source>
<target> months ago</target>
</trans-unit>
<trans-unit id="r7fyHp0" resname=" days ago">
<source> days ago</source>
<target> days ago</target>
</trans-unit>
<trans-unit id="mga12oW" resname=" hours ago">
<source> hours ago</source>
<target> hours ago</target>
</trans-unit>
<trans-unit id="BAlvYYB" resname=" minutes ago">
<source> minutes ago</source>
<target> minutes ago</target>
</trans-unit>
<trans-unit id="m4YrK9n" resname=" seconds ago">
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@ -693,6 +693,30 @@
<source>seconds ago</source> <source>seconds ago</source>
<target>seconds ago</target> <target>seconds ago</target>
</trans-unit> </trans-unit>
<trans-unit id="KGg3UPj" resname=" years ago">
<source> years ago</source>
<target> years ago</target>
</trans-unit>
<trans-unit id="LJz20sI" resname=" months ago">
<source> months ago</source>
<target> months ago</target>
</trans-unit>
<trans-unit id="r7fyHp0" resname=" days ago">
<source> days ago</source>
<target> days ago</target>
</trans-unit>
<trans-unit id="mga12oW" resname=" hours ago">
<source> hours ago</source>
<target> hours ago</target>
</trans-unit>
<trans-unit id="BAlvYYB" resname=" minutes ago">
<source> minutes ago</source>
<target> minutes ago</target>
</trans-unit>
<trans-unit id="m4YrK9n" resname=" seconds ago">
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@ -693,6 +693,30 @@
<source>seconds ago</source> <source>seconds ago</source>
<target>seconds ago</target> <target>seconds ago</target>
</trans-unit> </trans-unit>
<trans-unit id="KGg3UPj" resname=" years ago">
<source> years ago</source>
<target> years ago</target>
</trans-unit>
<trans-unit id="LJz20sI" resname=" months ago">
<source> months ago</source>
<target> months ago</target>
</trans-unit>
<trans-unit id="r7fyHp0" resname=" days ago">
<source> days ago</source>
<target> days ago</target>
</trans-unit>
<trans-unit id="mga12oW" resname=" hours ago">
<source> hours ago</source>
<target> hours ago</target>
</trans-unit>
<trans-unit id="BAlvYYB" resname=" minutes ago">
<source> minutes ago</source>
<target> minutes ago</target>
</trans-unit>
<trans-unit id="m4YrK9n" resname=" seconds ago">
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@ -693,6 +693,30 @@
<source>seconds ago</source> <source>seconds ago</source>
<target>seconds ago</target> <target>seconds ago</target>
</trans-unit> </trans-unit>
<trans-unit id="KGg3UPj" resname=" years ago">
<source> years ago</source>
<target> years ago</target>
</trans-unit>
<trans-unit id="LJz20sI" resname=" months ago">
<source> months ago</source>
<target> months ago</target>
</trans-unit>
<trans-unit id="r7fyHp0" resname=" days ago">
<source> days ago</source>
<target> days ago</target>
</trans-unit>
<trans-unit id="mga12oW" resname=" hours ago">
<source> hours ago</source>
<target> hours ago</target>
</trans-unit>
<trans-unit id="BAlvYYB" resname=" minutes ago">
<source> minutes ago</source>
<target> minutes ago</target>
</trans-unit>
<trans-unit id="m4YrK9n" resname=" seconds ago">
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@ -693,6 +693,30 @@
<source>seconds ago</source> <source>seconds ago</source>
<target>seconds ago</target> <target>seconds ago</target>
</trans-unit> </trans-unit>
<trans-unit id="KGg3UPj" resname=" years ago">
<source> years ago</source>
<target> years ago</target>
</trans-unit>
<trans-unit id="LJz20sI" resname=" months ago">
<source> months ago</source>
<target> months ago</target>
</trans-unit>
<trans-unit id="r7fyHp0" resname=" days ago">
<source> days ago</source>
<target> days ago</target>
</trans-unit>
<trans-unit id="mga12oW" resname=" hours ago">
<source> hours ago</source>
<target> hours ago</target>
</trans-unit>
<trans-unit id="BAlvYYB" resname=" minutes ago">
<source> minutes ago</source>
<target> minutes ago</target>
</trans-unit>
<trans-unit id="m4YrK9n" resname=" seconds ago">
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@ -693,6 +693,30 @@
<source>seconds ago</source> <source>seconds ago</source>
<target>seconds ago</target> <target>seconds ago</target>
</trans-unit> </trans-unit>
<trans-unit id="KGg3UPj" resname=" years ago">
<source> years ago</source>
<target> years ago</target>
</trans-unit>
<trans-unit id="LJz20sI" resname=" months ago">
<source> months ago</source>
<target> months ago</target>
</trans-unit>
<trans-unit id="r7fyHp0" resname=" days ago">
<source> days ago</source>
<target> days ago</target>
</trans-unit>
<trans-unit id="mga12oW" resname=" hours ago">
<source> hours ago</source>
<target> hours ago</target>
</trans-unit>
<trans-unit id="BAlvYYB" resname=" minutes ago">
<source> minutes ago</source>
<target> minutes ago</target>
</trans-unit>
<trans-unit id="m4YrK9n" resname=" seconds ago">
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@ -693,6 +693,30 @@
<source>seconds ago</source> <source>seconds ago</source>
<target>seconds ago</target> <target>seconds ago</target>
</trans-unit> </trans-unit>
<trans-unit id="KGg3UPj" resname=" years ago">
<source> years ago</source>
<target> years ago</target>
</trans-unit>
<trans-unit id="LJz20sI" resname=" months ago">
<source> months ago</source>
<target> months ago</target>
</trans-unit>
<trans-unit id="r7fyHp0" resname=" days ago">
<source> days ago</source>
<target> days ago</target>
</trans-unit>
<trans-unit id="mga12oW" resname=" hours ago">
<source> hours ago</source>
<target> hours ago</target>
</trans-unit>
<trans-unit id="BAlvYYB" resname=" minutes ago">
<source> minutes ago</source>
<target> minutes ago</target>
</trans-unit>
<trans-unit id="m4YrK9n" resname=" seconds ago">
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@ -693,6 +693,30 @@
<source>seconds ago</source> <source>seconds ago</source>
<target>seconds ago</target> <target>seconds ago</target>
</trans-unit> </trans-unit>
<trans-unit id="KGg3UPj" resname=" years ago">
<source> years ago</source>
<target> years ago</target>
</trans-unit>
<trans-unit id="LJz20sI" resname=" months ago">
<source> months ago</source>
<target> months ago</target>
</trans-unit>
<trans-unit id="r7fyHp0" resname=" days ago">
<source> days ago</source>
<target> days ago</target>
</trans-unit>
<trans-unit id="mga12oW" resname=" hours ago">
<source> hours ago</source>
<target> hours ago</target>
</trans-unit>
<trans-unit id="BAlvYYB" resname=" minutes ago">
<source> minutes ago</source>
<target> minutes ago</target>
</trans-unit>
<trans-unit id="m4YrK9n" resname=" seconds ago">
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@ -693,6 +693,30 @@
<source>seconds ago</source> <source>seconds ago</source>
<target>seconds ago</target> <target>seconds ago</target>
</trans-unit> </trans-unit>
<trans-unit id="KGg3UPj" resname=" years ago">
<source> years ago</source>
<target> years ago</target>
</trans-unit>
<trans-unit id="LJz20sI" resname=" months ago">
<source> months ago</source>
<target> months ago</target>
</trans-unit>
<trans-unit id="r7fyHp0" resname=" days ago">
<source> days ago</source>
<target> days ago</target>
</trans-unit>
<trans-unit id="mga12oW" resname=" hours ago">
<source> hours ago</source>
<target> hours ago</target>
</trans-unit>
<trans-unit id="BAlvYYB" resname=" minutes ago">
<source> minutes ago</source>
<target> minutes ago</target>
</trans-unit>
<trans-unit id="m4YrK9n" resname=" seconds ago">
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@ -693,6 +693,30 @@
<source>seconds ago</source> <source>seconds ago</source>
<target>seconds ago</target> <target>seconds ago</target>
</trans-unit> </trans-unit>
<trans-unit id="KGg3UPj" resname=" years ago">
<source> years ago</source>
<target> years ago</target>
</trans-unit>
<trans-unit id="LJz20sI" resname=" months ago">
<source> months ago</source>
<target> months ago</target>
</trans-unit>
<trans-unit id="r7fyHp0" resname=" days ago">
<source> days ago</source>
<target> days ago</target>
</trans-unit>
<trans-unit id="mga12oW" resname=" hours ago">
<source> hours ago</source>
<target> hours ago</target>
</trans-unit>
<trans-unit id="BAlvYYB" resname=" minutes ago">
<source> minutes ago</source>
<target> minutes ago</target>
</trans-unit>
<trans-unit id="m4YrK9n" resname=" seconds ago">
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>

View File

@ -693,6 +693,30 @@
<source>seconds ago</source> <source>seconds ago</source>
<target>секунд тому</target> <target>секунд тому</target>
</trans-unit> </trans-unit>
<trans-unit id="KGg3UPj" resname=" years ago">
<source> years ago</source>
<target> years ago</target>
</trans-unit>
<trans-unit id="LJz20sI" resname=" months ago">
<source> months ago</source>
<target> months ago</target>
</trans-unit>
<trans-unit id="r7fyHp0" resname=" days ago">
<source> days ago</source>
<target> days ago</target>
</trans-unit>
<trans-unit id="mga12oW" resname=" hours ago">
<source> hours ago</source>
<target> hours ago</target>
</trans-unit>
<trans-unit id="BAlvYYB" resname=" minutes ago">
<source> minutes ago</source>
<target> minutes ago</target>
</trans-unit>
<trans-unit id="m4YrK9n" resname=" seconds ago">
<source> seconds ago</source>
<target> seconds ago</target>
</trans-unit>
</body> </body>
</file> </file>
</xliff> </xliff>