From: Bharat M. <bh...@me...> - 2002-12-29 20:39:20
|
I'm already sold on this. Good work, Beckett. This whole process has been bugging me for a while, because I was unable to get pluralization working properly the first time around. I realize now that it's because I failed to read enough of the gettext manual (and I copied a bunch of concepts wholesale from the Horde project, which apparently isn't doing it the proper way either). I'm *much* happier with the solution you're proposing. It lets us really leverage gettext to do full pluralization translations, which is what I wanted all along. If we weren't going to do pluralization correctly we could have just gone with the much more simplistic approach that *Nuke took. I've checked in your new version of extract.pl and used it to regenerate all the .po files. Language maintainers will need to go through and retranslate parts of their .po files to adjust for this change. However, hopefully this is the last structural change that we'll have to make to the internationalization code. -Bharat From: "Beckett Madden-Woods" <be...@be...> > Okay. Progress on this front: > I've successfully implemented the dngettext() plurals. > In fact, the only change comes in *extract.pl*. > > I altered *extract.pl* to scan the files a little differently. > To keep the regexps from getting too grotesque, the code now scans for the > following format: > > m/\{\s*galleryText.*?[^\\]\})/sg > > and subsequently within this string for either: > > m/text="(.*?[^\\])"/s > or > m/(?=.*?one="(.*?[^\\])")(?=.*?many="(.*?[^\\])")/s > > This places conditions on the format, but this would pass: :) > > { galleryText many="......" > one="......" > foobar=$asdf} > > The text/one/many strings must use double-quotes and must backslash any > ___"___ double-quotes or ___}___ right curly braces (the latter condition > also breaks in the original code). Adding support for single quotes was just > too hard for my poor brain. I invite expert regexpers to take a shot at > relaxing these conditions, though. The code will print out the errant code > if single quotes are used, which is better than nothing. > > Anyhow, the new *extract.pl* outputs the following format: > > gettext("Monkeys grow on trees.") > gettext("Number of \"photos\": %d") > ngettext("You have %d monkey.", "You have %d monkeys.") > > versus the old format: > > _("Monkeys grow on trees.") > _("Number of \") <-- this one would break > _("You have %d monkey.") <-- > _("You have %d monkeys.") <--\- split up into two separate items > > Now, *xgettext* understands the new output right off the bat, so we can > change lib/tools/po/GNUmakefile.inc, line 29 > > xgettext --keyword=_ -C --no-location strings.raw > to > xgettext -C --no-location strings.raw > > Now, provided we've inputted the correct Plual-Forms header in the .po file, > everything works great, and the multiple plural support works. > > One problem I found is that the emacs po-mode doesn't work quite right with > the multiple msgstr[#] lines. For the last item, it thinks there should only > be one msgstr line, and seizes up. I had to switch modes to edit this last > item properly :/ (I'll send an e-mail to the GNU gettext team and find out > what's up with this). > > I'll come up with a quick working example on a webpage to sell you on this > change. :) > > -- > Beckett Madden-Woods | be...@be... > 109 Valentine Pl | (626) 590-0003 (mobile) > Ithaca, NY 14850-6139 | http://www.beckettmw.com > > > |