Boost logo

Boost :

Subject: [boost] [locale] Custom Gettext paths.
From: Jookia (166291_at_[hidden])
Date: 2012-08-20 22:43:00


I'm extremely happy about Boost.Locale, but I've found a few things
lacking. So at first I wrote a some wrappers to get around a few flaws
with my usage of Boost.Locale. One of these flaws was how it's hardcoded
to use the Gettext directory hierarchy.

I'd rather store my stuff in 'lang/' rather than

The patch adds a 'path format' feature, which allows you to format the
directory structure when finding Gettext catalogs, to achieve the effect
above. All you really have to do is run:

   gen.add_path_format("{1}/{2}.mo"); // Use a smaller hierarchy.

to achieve the result that I prefer, or

   gen.add_path_format("{1}/{2}/{3}/{4}.mo"); // Use a Gettext hierarchy.

to achieve the result that Boost.Locale uses right now. Ripped straight
from Doxygen comments:

   {1} A path to search for catalogs in.
   {2} The locale's name.
   {3} The locale's category.
   {4} The Gettext domain.

I'm new to submitting patches and things, and I'm not sure how I could
make this feature better or even acceptable if it isn't already, but I'm
sure it'd help others out there.

There are a few drawbacks I've found with my code:

- To be backwards compatible I've had to add some hackery to add the
Gettext format if the path formats vector is empty.

- Without consulting documentation, the format is unreadable.

- I haven't tested it on the Win32 backend. I'm 90% sure the code would
work, it's only 4 lines of code added and it's identical to the code
added in the other backends, but it's still untested code.

- It's not tested properly. By properly, I mean the tests past with
adding a format, and falling back to the default format, but I haven't
tried having a 'compact' format. I'm not sure if this would indicate a
fault in the formatting code though, as that'd be the only difference
code-wise, unless there's more code that has the Gettext hierarchy
hardcoded, that didn't fail when I didn't fix the tests.

The patch itself is based off of SVN r80097, and despite the diff being
for r80104 I haven't tested it in that.. I did the work internally in
Git but I made the patch using SVN, in case that matters. I've attached
the patch, but I'm not sure how well that's going to go over considering
I'm new to mailing lists, and I'm using.. Thunderbird.. Yeah. In case
the attachment fails, it's available at . I'd
also like to know if it's appropriate to put '[patch]' in the title for
any future patches, and if it should go after '[locale]' or at the end
of the title.


Boost list run by bdawes at, gregod at, cpdaniel at, john at