Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
Translations Class Reference

#include <translation.h>

+ Collaboration diagram for Translations:

Public Member Functions

void loadTranslation (const std::string &filename, const std::string &data)
 
void clear ()
 
const std::wstring & getTranslation (const std::wstring &textdomain, const std::wstring &s) const
 
const std::wstring & getPluralTranslation (const std::wstring &textdomain, const std::wstring &s, unsigned long int number) const
 
size_t size ()
 

Static Public Member Functions

static const std::string_view getFileLanguage (const std::string &filename)
 
static bool isTranslationFile (const std::string &filename)
 

Private Member Functions

void addTranslation (const std::wstring &textdomain, const std::wstring &original, const std::wstring &translated)
 
void addPluralTranslation (const std::wstring &textdomain, const GettextPluralForm::Ptr &plural, const std::wstring &original, std::vector< std::wstring > &translated)
 
std::wstring unescapeC (const std::wstring &str)
 
std::optional< std::pair< std::wstring, std::wstring > > parsePoLine (const std::string &line)
 
bool inEscape (const std::wstring &str, size_t pos)
 
void loadPoEntry (const std::wstring &basefilename, const GettextPluralForm::Ptr &plural_form, const std::map< std::wstring, std::wstring > &entry)
 
void loadMoEntry (const std::wstring &basefilename, const GettextPluralForm::Ptr &plural_form, const std::string &original, const std::string &translated)
 
void loadTrTranslation (const std::string &data)
 
void loadPoTranslation (const std::string &basefilename, const std::string &data)
 
void loadMoTranslation (const std::string &basefilename, const std::string &data)
 

Private Attributes

std::unordered_map< std::wstring, std::wstring > m_translations
 
std::unordered_map< std::wstring, std::pair< GettextPluralForm::Ptr, std::vector< std::wstring > > > m_plural_translations
 

Member Function Documentation

◆ addPluralTranslation()

void Translations::addPluralTranslation ( const std::wstring & textdomain,
const GettextPluralForm::Ptr & plural,
const std::wstring & original,
std::vector< std::wstring > & translated )
private

References errorstream, and m_plural_translations.

Referenced by loadMoEntry(), and loadPoEntry().

+ Here is the caller graph for this function:

◆ addTranslation()

void Translations::addTranslation ( const std::wstring & textdomain,
const std::wstring & original,
const std::wstring & translated )
private

References m_translations.

Referenced by loadMoEntry(), loadPoEntry(), and loadTrTranslation().

+ Here is the caller graph for this function:

◆ clear()

void Translations::clear ( )

References m_plural_translations, and m_translations.

Referenced by Game::startup().

+ Here is the caller graph for this function:

◆ getFileLanguage()

const std::string_view Translations::getFileLanguage ( const std::string & filename)
static

References removeStringEnd().

Referenced by Server::getTranslationLanguage(), and isTranslationFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPluralTranslation()

const std::wstring & Translations::getPluralTranslation ( const std::wstring & textdomain,
const std::wstring & s,
unsigned long int number ) const

References m_plural_translations.

Referenced by TEST_CASE(), and translate_string().

+ Here is the caller graph for this function:

◆ getTranslation()

const std::wstring & Translations::getTranslation ( const std::wstring & textdomain,
const std::wstring & s ) const

References m_translations.

Referenced by TEST_CASE(), and translate_string().

+ Here is the caller graph for this function:

◆ inEscape()

bool Translations::inEscape ( const std::wstring & str,
size_t pos )
private

Referenced by parsePoLine().

+ Here is the caller graph for this function:

◆ isTranslationFile()

static bool Translations::isTranslationFile ( const std::string & filename)
inlinestatic

References getFileLanguage().

Referenced by Client::loadMedia().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadMoEntry()

void Translations::loadMoEntry ( const std::wstring & basefilename,
const GettextPluralForm::Ptr & plural_form,
const std::string & original,
const std::string & translated )
private

References addPluralTranslation(), addTranslation(), str_split(), and utf8_to_wide().

Referenced by loadMoTranslation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadMoTranslation()

void Translations::loadMoTranslation ( const std::string & basefilename,
const std::string & data )
private

References errorstream, hex_encode(), loadMoEntry(), GettextPluralForm::parseHeaderLine(), readVarEndian(), str_split(), str_starts_with(), and utf8_to_wide().

Referenced by loadTranslation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadPoEntry()

void Translations::loadPoEntry ( const std::wstring & basefilename,
const GettextPluralForm::Ptr & plural_form,
const std::map< std::wstring, std::wstring > & entry )
private

References addPluralTranslation(), addTranslation(), errorstream, and wide_to_utf8().

Referenced by loadPoTranslation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadPoTranslation()

void Translations::loadPoTranslation ( const std::string & basefilename,
const std::string & data )
private

References errorstream, loadPoEntry(), GettextPluralForm::parseHeaderLine(), parsePoLine(), str_split(), str_starts_with(), utf8_to_wide(), and wide_to_utf8().

Referenced by loadTranslation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadTranslation()

void Translations::loadTranslation ( const std::string & filename,
const std::string & data )

References errorstream, loadMoTranslation(), loadPoTranslation(), loadTrTranslation(), removeStringEnd(), and str_split().

Referenced by GUIEngine::getContentTranslations(), Client::loadMedia(), and TEST_CASE().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadTrTranslation()

void Translations::loadTrTranslation ( const std::string & data)
private

References addTranslation(), errorstream, str_split(), str_starts_with(), trim(), and utf8_to_wide().

Referenced by loadTranslation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ parsePoLine()

std::optional< std::pair< std::wstring, std::wstring > > Translations::parsePoLine ( const std::string & line)
private

References errorstream, inEscape(), trim(), unescapeC(), and utf8_to_wide().

Referenced by loadPoTranslation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ size()

size_t Translations::size ( )
inline

References m_plural_translations, and m_translations.

Referenced by TEST_CASE().

+ Here is the caller graph for this function:

◆ unescapeC()

std::wstring Translations::unescapeC ( const std::wstring & str)
private

References errorstream, hex_digit_decode(), wide_add_codepoint(), and wide_to_utf8().

Referenced by parsePoLine().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_plural_translations

std::unordered_map<std::wstring, std::pair<GettextPluralForm::Ptr, std::vector<std::wstring> > > Translations::m_plural_translations
private

◆ m_translations

std::unordered_map<std::wstring, std::wstring> Translations::m_translations
private

The documentation for this class was generated from the following files: