vemcogroup / laravel-translation

Translation package for Laravel to scan for localisations and up/download to poeditor
MIT License
131 stars 14 forks source link

`translation:download` command is trimming all translations #11

Closed EpocDotFr closed 2 years ago

EpocDotFr commented 3 years ago

Hello all,

Say I have a translation in my source code which is formatted like this:

trans(' with :assets', ['assets' => $assets]); // Notice the whitespace prefixing the translation

In the POEditor interface, when translating this sentence to another language, the aforementioned whitespace should remain. Which is perfectly fine and well-handled by POEditor. It's even giving you a visual hint about this whitespace. Example in French:

image

However, when downloading translations using the translation:download command, all translations are trimmed. Excerpt from the resulting fr.json file:

" with :assets": "avec :assets",

Looks like it's on-purpose: src/Translation.php#L127. Why such trimming?

Thank you in advance!

eldor commented 3 years ago

Hi,

It's implemented to avoid whitespaces in keys in case of typos from developers. If you need it to not trim the keys, you are welcome to make a PR with a config variable and then do the trim or not based on that variable on the mentioned line: src/Translation.php#L127.

Otherwise i'll see if I can implement it in the upcoming weeks.

EpocDotFr commented 3 years ago

Will create an MR then, thanks 👍