OpenXcom
1.0
Open-source clone of the original X-Com
|
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 | load (const std::string &filename, ExtraStrings *extras) |
Loads the language from a YAML file. More... | |
std::string | getId () const |
Gets the language's ID. More... | |
std::wstring | getName () const |
Gets the language's name. More... | |
void | toHtml (const std::string &filename) const |
Outputs the language to a HTML file. More... | |
const LocalizedText & | getString (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 LocalizedText & | getString (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 std::string | wstrToUtf8 (const std::wstring &src) |
Converts a wide-string to UTF-8. More... | |
static std::string | wstrToCp (const std::wstring &src) |
Converts a wide-string to local-codepage string. More... | |
static std::string | wstrToFs (const std::wstring &src) |
Converts a wide-string to filesystem string. More... | |
static std::wstring | utf8ToWstr (const std::string &src) |
Converts a UTF-8 string to wide-string. More... | |
static std::wstring | cpToWstr (const std::string &src) |
Converts a local-codepage string to wide-string. More... | |
static std::wstring | fsToWstr (const std::string &src) |
Converts a filesystem string to wide-string. More... | |
static void | replace (std::string &str, const std::string &find, const std::string &replace) |
Replaces a substring. More... | |
static void | replace (std::wstring &str, const std::wstring &find, const std::wstring &replace) |
Replaces a substring. More... | |
static void | getList (std::vector< std::string > &files, std::vector< std::wstring > &names) |
Gets list of languages in the data directory. More... | |
Contains strings used throughout the game for localization.
Languages are just a set of strings identified by an ID string.
OpenXcom::Language::Language | ( | ) |
Creates a blank language.
Initializes an empty language file.
|
static |
Converts a local-codepage string to wide-string.
Takes an 8-bit string encoded in the current system codepage and converts it to a wide-character string.
src | Codepage string. |
|
static |
Converts a filesystem string to wide-string.
Takes an 8-bit string with the filesystem encoding and converts it to a wide-character string.
src | Filesystem string. |
std::string OpenXcom::Language::getId | ( | ) | const |
Gets the language's ID.
Returns the language's locale.
|
static |
Gets list of languages in the data directory.
Gets all the languages found in the Data folder and returns their properties.
files | List of language filenames. |
names | List of language human-readable names. |
std::wstring OpenXcom::Language::getName | ( | ) | const |
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.
id | ID of the string. |
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.
id | ID of the string. |
n | Number to use to decide the proper form. |
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.
id | ID of the string. |
gender | Current soldier gender. |
TextDirection OpenXcom::Language::getTextDirection | ( | ) | const |
Gets the direction of text in this language.
Returns the direction to use for rendering text in this language.
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.
void OpenXcom::Language::load | ( | const std::string & | filename, |
ExtraStrings * | extras | ||
) |
Loads the language from a YAML file.
Loads a language file in Ruby-on-Rails YAML format.
Not that this has anything to do with Ruby, but since it's a widely-supported format and we already have YAML, it was convenient.
filename | Filename of the YAML file. |
extras | Pointer to extra strings from ruleset. |
|
static |
Replaces a substring.
Replaces every instance of a substring.
str | The string to modify. |
find | The substring to find. |
replace | The substring to replace it with. |
|
static |
Replaces a substring.
Replaces every instance of a substring.
str | The string to modify. |
find | The substring to find. |
replace | The substring to replace it with. |
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.
filename | HTML file. |
|
static |
Converts a UTF-8 string to wide-string.
Takes an 8-bit string encoded in UTF-8 and converts it to a wide-character string.
src | UTF-8 string. |
|
static |
Converts a wide-string to local-codepage string.
Takes a wide-character string and converts it to an 8-bit string encoded in the current system codepage.
src | Wide-character string. |
|
static |
Converts a wide-string to filesystem string.
Takes a wide-character string and converts it to an 8-bit string with the filesystem encoding.
src | Wide-character string. |
|
static |
Converts a wide-string to UTF-8.
Takes a wide-character string and converts it to a 8-bit string encoded in UTF-8.
src | Wide-character string. |