Translator.h File Reference

This class is designed for dealing with multi-language text translation in TerraLib. More...

#include "../Config.h"
#include "../../BuildConfig.h"
#include <string>
#include <map>
#include <vector>

Go to the source code of this file.

Classes

class  te::core::Translator
 This singleton is designed to deal with multi-language text translation in TerraLib. More...
 

Namespaces

 te
 URI C++ Library.
 
 te::core
 

Macros

#define TE_ADD_TEXT_DOMAIN(domain, dir)   ((void)0)
 It adds the given text domain and its directory to the multilingual system. More...
 
#define TE_TR(message)   te::core::Translator::instance().translate(message).c_str()
 It marks a string in order to get translated. More...
 
#define TE_TR_LANGUAGE(locale)   te::core::Translator::instance().setLocale(locale)
 It sets the locale for the Translator. More...
 
#define TE_TR_PLURAL(message1, message2, n)   te::core::Translator::instance().translate(message1, message2, n).c_str()
 It marks a string in order to get translated according to plural form. More...
 

Detailed Description

This class is designed for dealing with multi-language text translation in TerraLib.

Author
Matheus Cavassan Zaglia
Gilberto Ribeiro de Queiroz

Definition in file Translator.h.

Macro Definition Documentation

#define TE_ADD_TEXT_DOMAIN (   domain,
  dir 
)    ((void)0)

It adds the given text domain and its directory to the multilingual system.

Parameters
domainA given message domain (just a name). A text domain is the name of the catalog used to translate the message.
dirWhere the text domain is located.

Definition at line 226 of file Translator.h.

#define TE_TR_LANGUAGE (   locale)    te::core::Translator::instance().setLocale(locale)

It sets the locale for the Translator.

Parameters
localeA string of the new locale.

Definition at line 279 of file Translator.h.

#define TE_TR_PLURAL (   message1,
  message2,
 
)    te::core::Translator::instance().translate(message1, message2, n).c_str()

It marks a string in order to get translated according to plural form.

Parameters
message1The singular form of the text to be translated.
message2The plural form of the text to be translated.
nThis parameter is used to determine the plural form.

Example of usage:

1 int n = f(...);
2 
3 std::cout << TE_TR_PLURAL("One Message!", "Two Messages", n);
4 
5 throw Exception(TE_TR_PLURAL("One Message!", "Two Messages", n));

In the above example, the parameter n can be a threshold that helps to choose between the first or the second construction. If your trabslation file is configured with a theashold of 1, indicating that if n > 1 must choose the second construction, the plural versin will be choosed, otherwise, it will choose the singular form (the fisrt one).

Definition at line 270 of file Translator.h.