Skip to content

Instantly share code, notes, and snippets.

@sudheesh001
Created January 10, 2014 03:07
Show Gist options
  • Save sudheesh001/8346371 to your computer and use it in GitHub Desktop.
Save sudheesh001/8346371 to your computer and use it in GitHub Desktop.
Messages and Locales are used in localization of content.
#include <iostream>
#include <locale>
int main()
{
std::locale loc("de_DE");
auto& facet = std::use_facet<std::messages<char>>(loc);
const char* dir = "/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.1/locale";
auto cat = facet.open("libstdc++", loc, dir);
std::cout << "\"please\" in German: "
<< facet.get(cat, 0, 0, "please") << '\n'
<< "\"thank you\" in German: "
<< facet.get(cat, 0, 0, "thank you") << '\n';
facet.close(cat);
}
/* Output
"please" in German: bitte
"thank you" in German: danke
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment