php-gettext / Gettext

PHP library to collect and manipulate gettext (.po, .mo, .php, .json, etc)
MIT License
687 stars 134 forks source link

XLIFF gererator trgLang matches srcLang #210

Open ScottAustin opened 5 years ago

ScottAustin commented 5 years ago

Hi,

When generating XLIFF the Translations language is used as the srcLang & trgLang. the spec states "Target language - the code of the language, in which the Translated text is expressed".

It could be fixed by adding the target language to the options array. $xliff->setAttribute('trgLang', $options['targetLanguage'] ?? $translations->getLanguage());

Any solution would be great

oscarotero commented 5 years ago

Ok, seems good.

My only concern is how to keep this info in both way: load a xliff, export to Po, load the Po, export to xliff.

Maybe we could save the value in a header, like X-Source-Language (not sure if there's a standard header name for this), so this value is present in any other format with headers. What do you think?

If you're ok with that, do you want to work in a PR?

ScottAustin commented 5 years ago

I'm happy to work on the PR for this.

Adding the data to the headers sounds like a good idea.