Closed EvilBozkurt closed 3 months ago
Headers are added in the Translations
instance.
$translations->getHeaders()->set('key', 'value');
And then you have to pass the translations instance to the Po generator:
$poGenerator = new PoGenerator();
$poGenerator->generateFile($translations, 'locales.po');
Headers are added in the
Translations
instance.$translations->getHeaders()->set('key', 'value');
And then you have to pass the translations instance to the Po generator:
$poGenerator = new PoGenerator(); $poGenerator->generateFile($translations, 'locales.po');
Thanks. Thanks to you I can make it work like this.
foreach ($phpScanner->getTranslations() as $domain => $translations) {
//seems to work, but po file does not seem to have the "language" header
$translations->setLanguage($domain);
$dosya_yolu = 'locales/' . $domain . '.po';
$translations->getHeaders()->set('Last-Translator', 'Mehmet Bozkurt');
if (file_exists($dosya_yolu)) {
$mevcut_translations = $loader->loadFile($dosya_yolu);
$updatedEntries = $translations->mergeWith($mevcut_translations);
$generator->generateFile($updatedEntries, "locales/$domain.po");
} else {
$generator->generateFile($translations, "locales/$domain.po");
}
}
I want to ask two questions. How can I define headers when using the PO file generator? And after I translate, when I produce a file, all the translated words disappear. How should I deal with this problem?