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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -