php - Build a Gettext Wrapper -


these days i'm working on 2 projects based on laravel , have implement localization. found out used method using gettext. have difficulties translating strings gettext() , ngettext(). i'd build wrapper able translate strings so:

fantasticfunction('hi name :name , have {n, 1 friend, :n friends}', [ 'name' => 'luca', 'n' => 1 ]) 

instead of writing:

sprintf('hi name %s , have', name) . ' ' . $n . ngettext('friend', 'friends', $n) 

so problem is: if i'd make such wrapper, tools poedit not recognize strings. how can solve?

you need add fantasticfunction keyword extraction — documented in xgettext docs , poedit has properties ui it.

but nothing {n, 1 friend, :n friends} thingie. if decided use gettext, need follow model , isn't compatible it. have @ how ngettext works , read on plural forms in different languages in gettext before inventing own approach. you're vague "difficulties" using gettext's plurals support (which speaking competently done), sure isn't case of nih syndrome?


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -