Gettext icon indicating copy to clipboard operation
Gettext copied to clipboard

translations findById

Open ouhman opened this issue 3 years ago • 2 comments

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,

ouhman avatar Feb 22 '22 13:02 ouhman

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!

oscarotero avatar Feb 22 '22 13:02 oscarotero

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.

ouhman avatar Feb 22 '22 14:02 ouhman