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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -