OpenXcom  1.0
Open-source clone of the original X-Com
Public Member Functions | Static Public Member Functions | List of all members
OpenXcom::Language Class Reference

Contains strings used throughout the game for localization. More...

#include <Language.h>

Public Member Functions

 Language ()
 Creates a blank language. More...
 
 ~Language ()
 Cleans up the language.
 
void loadFile (const std::string &filename)
 Loads the language from an external file. More...
 
void loadRule (const std::map< std::string, ExtraStrings *> &extraStrings, const std::string &id)
 Loads the language from a ruleset file. More...
 
std::string getId () const
 Gets the language's ID. More...
 
std::string getName () const
 Gets the language's name. More...
 
void toHtml (const std::string &filename) const
 Outputs the language to a HTML file. More...
 
const LocalizedTextgetString (const std::string &id) const
 Get a localized text. More...
 
LocalizedText getString (const std::string &id, unsigned n) const
 Get a quantity-depended localized text. More...
 
const LocalizedTextgetString (const std::string &id, SoldierGender gender) const
 Get a gender-depended localized text. More...
 
TextDirection getTextDirection () const
 Gets the direction of text in this language. More...
 
TextWrapping getTextWrapping () const
 Gets the wrapping of text in this language. More...
 

Static Public Member Functions

static void getList (std::vector< std::string > &files, std::vector< std::string > &names)
 Gets list of languages in the data directory. More...
 

Detailed Description

Contains strings used throughout the game for localization.

Languages are just a set of strings identified by an ID string.

Constructor & Destructor Documentation

◆ Language()

OpenXcom::Language::Language ( )

Creates a blank language.

Initializes an empty language file.

Member Function Documentation

◆ getId()

std::string OpenXcom::Language::getId ( ) const

Gets the language's ID.

Returns the language's locale.

Returns
IANA language tag.

◆ getList()

void OpenXcom::Language::getList ( std::vector< std::string > &  files,
std::vector< std::string > &  names 
)
static

Gets list of languages in the data directory.

Gets all the languages found in the Data folder and returns their properties.

Parameters
filesList of language filenames.
namesList of language human-readable names.

◆ getName()

std::string OpenXcom::Language::getName ( ) const

Gets the language's name.

Returns the language's name in its native language.

Returns
Language name.

◆ getString() [1/3]

const LocalizedText & OpenXcom::Language::getString ( const std::string &  id) const

Get a localized text.

Returns the localized text with the specified ID.

If it's not found, just returns the ID.

Parameters
idID of the string.
Returns
String with the requested ID.

◆ getString() [2/3]

LocalizedText OpenXcom::Language::getString ( const std::string &  id,
unsigned  n 
) const

Get a quantity-depended localized text.

Returns the localized text with the specified ID, in the proper form for n.

The substitution of n has already happened in the returned LocalizedText. If it's not found, just returns the ID.

Parameters
idID of the string.
nNumber to use to decide the proper form.
Returns
String with the requested ID.

◆ getString() [3/3]

const LocalizedText & OpenXcom::Language::getString ( const std::string &  id,
SoldierGender  gender 
) const

Get a gender-depended localized text.

Returns the localized text with the specified ID, in the proper form for the gender.

If it's not found, just returns the ID.

Parameters
idID of the string.
genderCurrent soldier gender.
Returns
String with the requested ID.

◆ getTextDirection()

TextDirection OpenXcom::Language::getTextDirection ( ) const

Gets the direction of text in this language.

Returns the direction to use for rendering text in this language.

Returns
Text direction.

◆ getTextWrapping()

TextWrapping OpenXcom::Language::getTextWrapping ( ) const

Gets the wrapping of text in this language.

Returns the wrapping rules to use for rendering text in this language.

Returns
Text wrapping.

◆ loadFile()

void OpenXcom::Language::loadFile ( const std::string &  path)

Loads the language from an external file.

Loads a language file from an external path.

Parameters
pathLanguage file path.

◆ loadRule()

void OpenXcom::Language::loadRule ( const std::map< std::string, ExtraStrings *> &  extraStrings,
const std::string &  id 
)

Loads the language from a ruleset file.

Loads a language file from a mod's ExtraStrings.

Parameters
extraStringsList of ExtraStrings.
idLanguage ID.

◆ toHtml()

void OpenXcom::Language::toHtml ( const std::string &  filename) const

Outputs the language to a HTML file.

Outputs all the language IDs and strings to an HTML table.

Parameters
filenameHTML file.

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