I have a non-Symfony PHP project in which I want to use Symfony Translate component with MoFileLoader. I have setup PoEdit so it recognizes trans("string") function when parsing file looking for translations.
This part of code <?php echo $translator->trans("Welcome"); ?>
is parsed as it should be.
Problem is I can't make PoEdit to recognize this as plural string <?php echo $translator->trans('Found {result} search result', ['{result}' => 1]); ?>
1 is clearly number of results and with that data I want to be able to use correct plural string.
Big issue is that my main language is Croatian which plural form nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);
is way more complex than English one nplurals=2; plural=(n!=1)
I have added this Sources keywords in PoEdit
trans
trans:1,2
I already tried to use PHP and gettext to accomplish this but it is just not working for me due to server restrictions and other problems with gettex, Apache and PHP.
This is the way I'm using Symfony Translate component:
<?php
require_once __DIR__.'/vendor/autoload.php';
use Symfony\Component\Translation\Translator;
use Symfony\Component\Translation\MessageSelector;
use Symfony\Component\Translation\Loader\MoFileLoader;
$lang = "hr";
$translator = new Translator($lang, new MessageSelector());
$translator->setFallbackLocales(['en']);
$translator->addLoader('mo', new MoFileLoader());
$translator->addResource('mo', "locale/$lang/LC_MESSAGES/messages.mo", $lang);
echo $translator->trans("Welcome");
echo $translator->trans('Found {result} search result', ['{result}' => 1]);
?>
Is there a way to make PoEdit recognize this as plural string:
<?php echo $translator->trans('Found {result} search result', ['{result}' => 1]); ?>