![]() |
NDEVR
API Documentation
|
Provides language translation services for the application. More...
Public Member Functions | |
| Translator () | |
| Constructs a default Translator with no language loaded. | |
| Translator (const File &settings_file) | |
| Constructs a Translator from a settings file on disk. | |
| Translator (const StringView &translation_id) | |
| Constructs a Translator for the specified translation identifier. | |
| Translator (const Translator &translator) | |
| Copy constructor. | |
| File | activeTranslatorFile () const |
| Returns the file path of the currently active translator file. | |
| virtual void | append (String &append, const String &text_string) const |
| Appends a translated version of the given text string. | |
| virtual void | append (String &append, const UUID &id, const String &default_text) const |
| Appends a translated string looked up by UUID, falling back to a default. | |
| String | commonCharacters () const |
| Returns a string containing the most common characters for this language. | |
| virtual String | convertNumber (const String &number_string, bool add_comma, uint04 min_decimals, uint04 max_decimals, uint04 min_digits) const |
| Converts a numeric string into a locale-appropriate formatted string. | |
| void | copyFrom (const Translator &trans, bool use_existing_ini_file) |
| Copies translation settings from another Translator. | |
| void | copyTranslationsFrom (const Translator &trans) |
| Copies only the translated string entries from another Translator. | |
| void | getINI (INIFactory &factory) override |
| Populates or reads translation data from the given INI factory. | |
| const String & | id () const |
| Returns the identifier of this translation. | |
| bool | isLeftToRight () const |
| Returns whether this language reads left-to-right. | |
| const String & | name () const |
| Returns the human-readable name of this language. | |
| Translator & | operator= (const Translator &translation) |
| Assignment operator. | |
| void | saveTranslation (File location=File()) |
| Saves the current translation data to a file. | |
| void | setID (const StringView &id) |
| Sets the translation identifier. | |
| void | setName (const StringView &name) |
| Sets the human-readable language name. | |
| const Dictionary< UUID, String > & | translatedStrings () const |
| Returns the dictionary of all translated strings keyed by UUID. | |
| INIFactory & | translationINI () const |
| Returns a reference to the INI factory managing translation entries. | |
| File | translatorFile (bool user_file) const |
| Returns the file path for the translator data file. | |
| Public Member Functions inherited from INIInterface | |
| INIInterface () | |
| Constructs an INIInterface with no default INI file. | |
| INIInterface (const File &default_ini) | |
| Constructs an INIInterface with the specified default INI file. | |
| virtual | ~INIInterface () |
| Virtual destructor for safe polymorphic cleanup. | |
| virtual void | finishReadingINI (INIFactory &) |
| Called after reading an INI file. | |
| virtual void | prepareForINI (INIFactory &) |
| Called before reading or writing an INI file. | |
| virtual bool | readINIOptions () |
| Reads INI options from the default INI file. | |
| virtual bool | readINIOptions (File &ini_file) |
| Reads INI options from the specified INI file. | |
| virtual bool | saveINIOptions (bool multithead=false) |
| Saves INI options to the default INI file. | |
| virtual bool | saveINIOptions (File &ini_file, bool multithead=false) |
| Saves INI options to the specified INI file. | |
| void | setDefaultINIFile (const File &file) |
| Sets the default INI file path used for reading and writing options. | |
| virtual void | writeToLog (const StringView &title, LogPtr log, uint01 log_level=2U) |
| Writes the current INI options to the specified log with a title. | |
| virtual void | writeToLog (LogPtr log, uint01 log_level=2U) |
| Writes the current INI options to the specified log. | |
Static Public Member Functions | |
| static UUID | DefaultFastID (const StringView &text_string) |
| Computes a UUID for the given text string using a fast hashing method. | |
| static UUID | DefaultID (const StringView &text_string) |
| Computes a default UUID for the given text string. | |
| static String | DefaultReadableLabel (const StringView &text_string) |
| Generates a default human-readable label from a text string. | |
| static String | DefaultReadableLabel (const UUID &text_string) |
| Generates a default human-readable label from a UUID. | |
| static Dictionary< String, Translator > | GetAvailableTranslations (File folder=File()) |
| Discovers all available translation files in the given folder. | |
| static Translator * | MainTranslator () |
| Returns the application's main Translator instance. | |
| static Translator * | MainTranslator (const StringView &language) |
| Returns the main Translator for a specific language. | |
| static void | SetMainTranslator (Translator *translator) |
| Sets the application's main Translator instance. | |
Static Public Attributes | |
| static Resource< Translator * > | main_translator |
| The global main translator resource. | |
| static Dictionary< String, Translator * > | translators |
| Registry of all loaded translators keyed by language ID. | |
Protected Member Functions | |
| void | ensureLanguageLoaded () const |
| Lazily loads the language data from disk if not already loaded. | |
| void | init () |
| Initializes internal state for the Translator. | |
Protected Attributes | |
| String | m_common_characters |
| A string of commonly used characters in this language. | |
| char | m_decimal_sep |
| The decimal separator character (typically '.'). | |
| bool | m_has_loaded_language |
| Whether the language data has been loaded from disk. | |
| INIFactory | m_language_ini |
| The INI factory managing the language translation file. | |
| String | m_language_name |
| The human-readable name of the language. | |
| bool | m_left_to_right |
| Whether the language reads left-to-right (typically true). | |
| char | m_number_sep |
| The thousands separator character (typically ','). | |
| Dictionary< UUID, String > | m_translated_strings |
| Cached dictionary of translated strings keyed by UUID. | |
| File | m_translation_file |
| The file path of the translation data. | |
| String | m_translation_id |
| The unique identifier for this translation. | |
| Protected Attributes inherited from INIInterface | |
| File | m_default_ini |
| The default file path used for reading and writing INI options. | |
Provides language translation services for the application.
Manages loading, storing, and applying translations from INI-based language files. Supports number formatting, text direction, and lookup of translated strings by UUID. A global main translator instance is available for application-wide use.
Definition at line 60 of file Translator.h.
| Translator::Translator | ( | const StringView & | translation_id | ) |
Constructs a Translator for the specified translation identifier.
| [in] | translation_id | The identifier of the language translation to use. |
| Translator::Translator | ( | const File & | settings_file | ) |
Constructs a Translator from a settings file on disk.
| [in] | settings_file | The INI file containing translation data. |
| Translator::Translator | ( | const Translator & | translator | ) |
| File Translator::activeTranslatorFile | ( | ) | const |
Returns the file path of the currently active translator file.
| String Translator::commonCharacters | ( | ) | const |
Returns a string containing the most common characters for this language.
|
virtual |
Converts a numeric string into a locale-appropriate formatted string.
| [in] | number_string | The raw number string to format. |
| [in] | add_comma | Whether to insert thousands separators. |
| [in] | min_decimals | The minimum number of decimal places to display. |
| [in] | max_decimals | The maximum number of decimal places to display. |
| [in] | min_digits | The minimum number of integer digits to display. |
| void Translator::copyFrom | ( | const Translator & | trans, |
| bool | use_existing_ini_file ) |
Copies translation settings from another Translator.
| [in] | trans | The source Translator to copy from. |
| [in] | use_existing_ini_file | Whether to reuse the existing INI file rather than replacing it. |
References Translator().
| void Translator::copyTranslationsFrom | ( | const Translator & | trans | ) |
Copies only the translated string entries from another Translator.
| [in] | trans | The source Translator whose translations are copied. |
References Translator().
|
static |
|
static |
|
static |
Generates a default human-readable label from a text string.
| [in] | text_string | The raw text to convert to a readable label. |
Referenced by TranslationTools::addOption(), TranslationTools::setupFile(), and QCustomTranslator::translate().
|
static |
Discovers all available translation files in the given folder.
| [in] | folder | The folder to search. If empty, uses the default location. |
|
overridevirtual |
Populates or reads translation data from the given INI factory.
| [in] | factory | The INI factory used for serialization. |
Implements INIInterface.
|
inline |
Returns the identifier of this translation.
Definition at line 142 of file Translator.h.
References m_translation_id.
| bool Translator::isLeftToRight | ( | ) | const |
Returns whether this language reads left-to-right.
|
static |
Returns the application's main Translator instance.
References Translator().
|
static |
Returns the main Translator for a specific language.
| [in] | language | The language identifier to look up. |
References Translator().
|
inline |
Returns the human-readable name of this language.
Definition at line 147 of file Translator.h.
References m_language_name.
Referenced by setName().
| Translator & Translator::operator= | ( | const Translator & | translation | ) |
Assignment operator.
| [in] | translation | The Translator to assign from. |
References Translator().
Saves the current translation data to a file.
| [in] | location | The file to save to. If empty, uses the default location. |
| void Translator::setID | ( | const StringView & | id | ) |
Sets the translation identifier.
| [in] | id | The new translation ID. |
|
static |
Sets the application's main Translator instance.
| [in] | translator | A pointer to the Translator to use as the main translator. |
References Translator().
| void Translator::setName | ( | const StringView & | name | ) |
| const Dictionary< UUID, String > & Translator::translatedStrings | ( | ) | const |
Returns the dictionary of all translated strings keyed by UUID.
| INIFactory & Translator::translationINI | ( | ) | const |
Returns a reference to the INI factory managing translation entries.
| File Translator::translatorFile | ( | bool | user_file | ) | const |
Returns the file path for the translator data file.
| [in] | user_file | Whether to return the user-specific file rather than the system file. |