Open withinboredom opened 2 years ago
This is not well documented at all by them
That makes it somewhat hard to support… Even your example is a bit ambiguous (count
and count_var
are intentional or a typo, and if not, mean what?).
That makes it somewhat hard to support…
And just as annoying to use. :joy: It doesn't help that they have the issue tracker disabled too. For plurals, I'll probably just end up passing it as a template variable and have regular gettext do the translating in PHP.
count and count_var are intentional or a typo, and if not, mean what?
count
is an attribute, it will always be count
while count_var
is a variable holding the current count.
Would you have some example files? I can't find any in their repository...
I managed to find some examples in their unit tests:
Jesus. Now a bit of the parser makes sense. It looks like if there is just a %count%
variable in the text, it will use that as the count. This is a strange syntax: ]1,Inf]
which I imagine is some way to say from 1 (exclusive) to infinity (inclusive). Shame they literally don't document this anywhere, I'll have to experiment with it.
Here is a full example of the syntax:
{0}I don't have apples|{1}I have one apple|]1,Inf[I have %count% apples
More details in the Sf documentation: https://symfony.com/doc/5.4/translation.html#message-format
More details in the Sf documentation: https://symfony.com/doc/5.4/translation.html#message-format
There aren't more details there, though. This one limited example is literally all there is written on the subject of non-ICU formatting.
Here's the latest version of their test following up on @withinboredom: https://github.com/symfony/twig-bridge/blob/6.1/Tests/Extension/TranslationExtensionTest.php
There is a lot of information in the comments of this class: https://github.com/symfony/contracts/blob/main/Translation/TranslatorInterface.php
With the deprecation of https://github.com/twigphp/Twig-extensions and switching over to https://github.com/symfony/twig-bridge, it appears Symfony has
subtlydrastically changed how pluralization works.Former:
Now:
Is there anyway that poedit can recognize the
|
to delineate the singular/plural form?This is not well documented at all by them, and I had to go digging into the parser to figure out how to make it work 😂