php-gettext / Gettext

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

translations findById #281

Open ouhman opened 2 years ago

ouhman commented 2 years ago

Hello,

First of all thanks for the work on this library, highly appreciated :)

Second, I would like to be able to find translations by their ids. Currently it is only possible to search by translations. https://github.com/php-gettext/Gettext/blob/master/src/Translations.php#L169

May I propose a PR to implement the changes? It should be fairly easy to implement.

Cheers,

oscarotero commented 2 years ago

Hi. In most cases the id is generated with the context + original text (See here: https://github.com/php-gettext/Gettext/blob/master/src/Translation.php#L34) But it's possible to use different ids so your proposal is fine. Feel free to create a PR. Thanks!

ouhman commented 2 years ago

Thank you for your answer. We don't use context and the id holds the original source language in our case.

I will be submitting a PR in the next days.