tanmuhittin / laravel-google-translate

Translate translation files to other languages using google translate or another translation api
MIT License
424 stars 71 forks source link

unnecessary spaces when translating plurals #14

Open hoRacy opened 5 years ago

hoRacy commented 5 years ago

I notice some unnecessary spaces when translating keys for plural. This cause the incorrect handling by laravel trans_choice() function.

there is

return array ( 'restaurants' => '{0} :count Restaurants | {1} :count Restaurant | [2.4] :count Restaurants | [5, *] :count Restaurants', );

should be

return array ( 'restaurants' => '{0} :count Restaurants|{1} :count Restaurant|[2.4] :count Restaurants|[5, *] :count Restaurants' );

tanmuhittin commented 5 years ago

This is probably due to google translate itself. When I tried to translate hello|world to Turkish it is translated as merhaba | Dünya.

hoRacy commented 5 years ago

Thanks, maybe good solution is to programmatically trim spaces around "|" char?

tanmuhittin commented 5 years ago

What if there is spaces in the input text where these spaces should be preserved? So, comparing the spaces around | character with the input text would be a better solution.