![]() |
NDEVR
API Documentation
|
Any text displayed to the user should be defined as a TranslatedString which allows the program to look up a translation, if available. More...
Public Member Functions | |
| TranslatedString () | |
| Constructs an empty TranslatedString with no translation or English text. | |
| TranslatedString (const StringView &raw_string) | |
| Constructs a TranslatedString from a raw string, computing a translation ID from the content. | |
| TranslatedString (const TranslatedString &translation) | |
| Copy constructor. | |
| TranslatedString (const UUID &translation_id, const StringView &english) | |
| Constructs a TranslatedString with an explicit translation ID and English text. | |
| TranslatedString (TranslatedString &&translation) noexcept | |
| Move constructor. | |
| ~TranslatedString () | |
| Destructor. | |
| bool | canReplaceInTranslation (const StringView &id) const |
| Checks whether the given identifier exists as a replaceable placeholder in this translation. | |
| const String & | englishDefine () const |
| Returns the original English definition string. | |
| String | englishTranslation () const |
| Returns the English translation of this string. | |
| bool | hasReplacements () const |
| Checks whether this string has any placeholder replacements applied. | |
| String | internalValue () const |
| Returns the internal representation of this translated string, including replacement markers. | |
| bool | isEmpty () const |
| Checks whether this translated string is empty (has no English text or translation). | |
| bool | isTranslatable () const |
| Checks whether this string has a translation ID and can be translated. | |
| bool | operator!= (const TranslatedString &translation) const |
| Inequality comparison operator. | |
| bool | operator< (const TranslatedString &value) const |
| Less-than comparison operator, compares by English translation. | |
| TranslatedString & | operator= (const TranslatedString &translation) noexcept |
| Copy assignment operator. | |
| TranslatedString & | operator= (TranslatedString &&translation) noexcept |
| Move assignment operator. | |
| bool | operator== (const TranslatedString &translation) const |
| Equality comparison operator. | |
| bool | operator> (const TranslatedString &value) const |
| Greater-than comparison operator, compares by English translation. | |
| const String | readableID () const |
| Returns a human-readable identifier for this translated string, useful for debugging. | |
| TranslatedString & | replace (const StringView &sub_string, const StringView &replacement) |
| Replaces occurrences of a placeholder substring with a raw string replacement. | |
| TranslatedString & | replace (const StringView &sub_string, const TranslatedString &replacement) |
| Replaces occurrences of a placeholder substring with a translated replacement. | |
| void | replaceVals (String &value) const |
| Applies all stored replacement values to the given string, substituting placeholders. | |
| void | retranslate () |
| Forces a retranslation of the cached translated string using the current language setting. | |
| StringView | translation () const |
| Returns the translated string for the current application language. | |
| String | translation (const String &language) const |
| Returns the translation of this string for a specific language. | |
| const UUID & | translationID () const |
| Returns the UUID that identifies this translatable string in the translation database. | |
Static Public Member Functions | |
| static void | AppendTranslated (const StringView &raw_string, String &string) |
| Appends the translated version of a raw string to an existing string. | |
| static TranslatedString | DirectString (const StringView &sub_string) |
| If a string does not have a translation (EG: reading from an already translated string) this operation ensures no translation will be attempted when calling translate on the resulting object. | |
Any text displayed to the user should be defined as a TranslatedString which allows the program to look up a translation, if available.
Definition at line 15 of file TranslatedString.h.
| TranslatedString::~TranslatedString | ( | ) |
Destructor.
Cleans up any replacement strings owned by this object.
| TranslatedString::TranslatedString | ( | const TranslatedString & | translation | ) |
Copy constructor.
Creates a TranslatedString from another.
| [in] | translation | The TranslatedString to copy. |
References TranslatedString(), and translation().
|
noexcept |
Move constructor.
Transfers ownership from another TranslatedString.
| [in] | translation | The TranslatedString to move from. |
References TranslatedString(), and translation().
|
explicit |
Constructs a TranslatedString from a raw string, computing a translation ID from the content.
| [in] | raw_string | The raw English string to use as the basis for translation. |
| TranslatedString::TranslatedString | ( | const UUID & | translation_id, |
| const StringView & | english ) |
Constructs a TranslatedString with an explicit translation ID and English text.
| [in] | translation_id | The UUID identifying the translation entry. |
| [in] | english | The English text for this translatable string. |
|
static |
Appends the translated version of a raw string to an existing string.
| [in] | raw_string | The raw string to translate and append. |
| [in] | string | The target string to append the translation to. |
| bool TranslatedString::canReplaceInTranslation | ( | const StringView & | id | ) | const |
Checks whether the given identifier exists as a replaceable placeholder in this translation.
| [in] | id | The placeholder identifier to search for. |
| const String & TranslatedString::englishDefine | ( | ) | const |
Returns the original English definition string.
| String TranslatedString::englishTranslation | ( | ) | const |
Returns the English translation of this string.
Referenced by HardwareCommandQueue< t_type >::getCommandCSVInfo(), HardwareCommandQueue< t_type >::getCommandJSONInfo(), HardwareCommandQueue< t_type >::setFromJSONInfo(), and ManagedDesignCommand::toString().
| bool TranslatedString::hasReplacements | ( | ) | const |
Checks whether this string has any placeholder replacements applied.
| String TranslatedString::internalValue | ( | ) | const |
Returns the internal representation of this translated string, including replacement markers.
| bool TranslatedString::isEmpty | ( | ) | const |
Checks whether this translated string is empty (has no English text or translation).
| bool TranslatedString::isTranslatable | ( | ) | const |
Checks whether this string has a translation ID and can be translated.
| bool TranslatedString::operator!= | ( | const TranslatedString & | translation | ) | const |
Inequality comparison operator.
| [in] | translation | The TranslatedString to compare against. |
References TranslatedString(), and translation().
| bool TranslatedString::operator< | ( | const TranslatedString & | value | ) | const |
Less-than comparison operator, compares by English translation.
| [in] | value | The TranslatedString to compare against. |
References TranslatedString().
|
noexcept |
Copy assignment operator.
| [in] | translation | The TranslatedString to copy. |
References TranslatedString(), and translation().
|
noexcept |
Move assignment operator.
| [in] | translation | The TranslatedString to move from. |
References TranslatedString(), and translation().
| bool TranslatedString::operator== | ( | const TranslatedString & | translation | ) | const |
Equality comparison operator.
| [in] | translation | The TranslatedString to compare against. |
References TranslatedString(), and translation().
| bool TranslatedString::operator> | ( | const TranslatedString & | value | ) | const |
Greater-than comparison operator, compares by English translation.
| [in] | value | The TranslatedString to compare against. |
References TranslatedString().
| const String TranslatedString::readableID | ( | ) | const |
Returns a human-readable identifier for this translated string, useful for debugging.
Referenced by GenericOptionGroup::getOption(), GenericOptionGroup::getOption(), and GenericOptionGroup::hasOption().
| TranslatedString & TranslatedString::replace | ( | const StringView & | sub_string, |
| const StringView & | replacement ) |
Replaces occurrences of a placeholder substring with a raw string replacement.
| [in] | sub_string | The placeholder substring to find. |
| [in] | replacement | The raw string to substitute in place of the placeholder. |
References TranslatedString().
| TranslatedString & TranslatedString::replace | ( | const StringView & | sub_string, |
| const TranslatedString & | replacement ) |
Replaces occurrences of a placeholder substring with a translated replacement.
| [in] | sub_string | The placeholder substring to find. |
| [in] | replacement | The TranslatedString to substitute in place of the placeholder. |
References TranslatedString().
Referenced by TimeFormatException::makeMessage().
| void TranslatedString::replaceVals | ( | String & | value | ) | const |
Applies all stored replacement values to the given string, substituting placeholders.
| [in] | value | The string in which to perform placeholder replacements. |
| StringView TranslatedString::translation | ( | ) | const |
Returns the translated string for the current application language.
Referenced by TranslatedString(), TranslatedString(), operator!=(), operator=(), operator=(), and operator==().
Returns the translation of this string for a specific language.
| [in] | language | The language code to translate into. |
| const UUID & TranslatedString::translationID | ( | ) | const |