translations.strings module

Provides translation functionality.

class translations.strings.LangStrings(infile, encoding='utf_8')[source]

Bases: dict

Dictionary class used to store all strings for a plugin.

__init__(infile, encoding='utf_8')[source]

Add all strings and fix double escaped strings.


Create a server specific langstrings file.

static _replace_escaped_sequences(given_string)[source]

Fix all double escaped strings.

get_strings(key, **tokens)[source]

Return a TranslationStrings object with updated tokens.

class translations.strings.TranslationStrings[source]

Bases: dict

Stores and get language strings for a particular string.


Store an empty dictionary as the tokens.

static _update_exposed_tokens(exposed_tokens, language, tokens, **kwargs)[source]

Return the language to be used.

get_string(language=None, **tokens)[source]

Return the language string for the given language/tokens.


Create a new TranslationStrings instance and store tokens in it.

Parameters:tokens (dict) – Tokens to store in the instance.
Returns:New TranslationStrings instance with tokens stored in it.
Return type:TranslationStrings