qi::Translator

This API allows you to translate your program. Read the internationalization guide for more detail.

Reference

qi::Translator Class Reference

Introduction

Localization of your source code. More...

#include <qi/translator.hpp>
  • Inherits: noncopyable

Public Functions

Translator(const std::string& name)
~Translator()
std::string translate(const std::string& msg, const std::string& domain, const std::string& locale, const std::string& context)
std::string translateContext(const std::string& msg, const std::string& context)
void setCurrentLocale(const std::string& locale)
void setDefaultDomain(const std::string& domain)
void addDomain(const std::string& domain)

Detailed Description

make your application or library speak in the user’s language.

Function Documentation

qi::Translator::Translator(const std::string& name)

Brief: Constructor.

Parameters:
  • name – Application or Library name
qi::Translator::~Translator()
std::string qi::Translator::translate(const std::string& msg, const std::string& domain = "", const std::string& locale = "", const std::string& context = "")

Brief: Translate a message.

Parameters:
  • msg – Message to translate
  • domain – Domain name
  • locale – Locale name
  • context – Context of the msg
Returns:

The translated message

std::string qi::Translator::translateContext(const std::string& msg, const std::string& context)

Brief: Translate a message with a specific context.

Parameters:
  • msg – Message to translate
  • context – Context of the msg
Returns:

The translated message

void qi::Translator::setCurrentLocale(const std::string& locale)

Brief: Change the locale at runtime.

Parameters:
  • locale – Locale name formatted as xx_XX (country and language code).
void qi::Translator::setDefaultDomain(const std::string& domain)

Brief: Set the default Domain.

Parameters:
  • domain – Domain name.
void qi::Translator::addDomain(const std::string& domain)

Brief: Add a new dicationary of messages.

Parameters:
  • domain – Domain name.
qi::Translator& qi::defaultTranslator(const std::string& name)

Brief: Get a reference on the default Translator.

Parameters:
  • name – Application or Library name
Returns:

A reference on default qi::Translator

qi::tr(const std::string&, const std::string&, const std::string&)