Boost logo

Boost :

Subject: [boost] [Locale] translate() couples key and output character widths
From: Alexander Lamaison (awl03_at_[hidden])
Date: 2013-12-20 06:01:44


I've finally gotten round to changing from the pre-release version of
Boost.Locale (v2.92) to the version now in Boost, and I was quite
surprised by one change. Previously, I could do the following:

void function_takes_wide_string(std::wstring message);

function_takes_wide_string(boost::locale::translate("My translation key"));

However, with the new version, the key must be passed in as a wide string
if I am to be able to get a wide string out. This means changing
`translate("blah")` to `translate(L"blah")` throughout.

The change itself is no big deal, but the problem is that it feels like
a change for the worse. The character width of the key is now coupled
to the character width of the output, when the two are separate concepts
and should be allowed to vary independently. The old class `message`
coeerced the string to whichever width was required. The new class
`basic_message<T>` coerces only to `basic_string<T>` and, worse than
that, doesn't provide a method to explicitly convert to a different
width string.

My question, I suppose, is why was this change made? What makes the new
API better?

Alex

-- 
Swish - Easy SFTP for Windows Explorer (http://www.swish-sftp.org)

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk