34#include <NDEVR/String.h>
35#include <NDEVR/INIFactory.h>
36#include <NDEVR/File.h>
37#include <NDEVR/Dictionary.h>
38#include <NDEVR/INIInterface.h>
39#include <NDEVR/UUID.h>
254 #define _t(english_string) (TranslatedString(Translator::DefaultID(english_string), english_string))
256 #define _tn(number_string, add_comma, min_decimals, max_decimals, min_digits) (Translator::MainTranslator()->convertNumber(number_string, add_comma, min_decimals, max_decimals, min_digits))
258 #define _td(def, english_string) (TranslatedString(Translator::DefaultFastID(def), english_string))
A hash-based key-value store, useful for quick associative lookups.
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Contains methods for easily reading and writing to an INI file including efficient casting,...
INIInterface()
Constructs an INIInterface with no default INI file.
A core part of the engine, stores variables that can be listened to with ResourceListener which will ...
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
virtual void append(String &append, const String &text_string) const
Appends a translated version of the given text string.
void init()
Initializes internal state for the Translator.
static Dictionary< String, Translator * > translators
Registry of all loaded translators keyed by language ID.
Translator & operator=(const Translator &translation)
Assignment operator.
Translator()
Constructs a default Translator with no language loaded.
Dictionary< UUID, String > m_translated_strings
Cached dictionary of translated strings keyed by UUID.
String m_common_characters
A string of commonly used characters in this language.
void copyFrom(const Translator &trans, bool use_existing_ini_file)
Copies translation settings from another Translator.
char m_number_sep
The thousands separator character (typically ',').
static Resource< Translator * > main_translator
The global main translator resource.
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.
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.
Translator(const Translator &translator)
Copy constructor.
const String & id() const
Returns the identifier of this translation.
bool isLeftToRight() const
Returns whether this language reads left-to-right.
void saveTranslation(File location=File())
Saves the current translation data to a file.
File translatorFile(bool user_file) const
Returns the file path for the translator data file.
INIFactory & translationINI() const
Returns a reference to the INI factory managing translation entries.
void copyTranslationsFrom(const Translator &trans)
Copies only the translated string entries from another Translator.
void ensureLanguageLoaded() const
Lazily loads the language data from disk if not already loaded.
void getINI(INIFactory &factory) override
Populates or reads translation data from the given INI factory.
const Dictionary< UUID, String > & translatedStrings() const
Returns the dictionary of all translated strings keyed by UUID.
void setName(const StringView &name)
Sets the human-readable language name.
static String DefaultReadableLabel(const StringView &text_string)
Generates a default human-readable label from a text string.
String m_translation_id
The unique identifier for this translation.
static void SetMainTranslator(Translator *translator)
Sets the application's main Translator instance.
static UUID DefaultID(const StringView &text_string)
Computes a default UUID for the given text string.
Translator(const StringView &translation_id)
Constructs a Translator for the specified translation identifier.
static UUID DefaultFastID(const StringView &text_string)
Computes a UUID for the given text string using a fast hashing method.
static Translator * MainTranslator(const StringView &language)
Returns the main Translator for a specific language.
static Translator * MainTranslator()
Returns the application's main Translator instance.
char m_decimal_sep
The decimal separator character (typically '.').
const String & name() const
Returns the human-readable name of this language.
static Dictionary< String, Translator > GetAvailableTranslations(File folder=File())
Discovers all available translation files in the given folder.
bool m_left_to_right
Whether the language reads left-to-right (typically true).
String commonCharacters() const
Returns a string containing the most common characters for this language.
File m_translation_file
The file path of the translation data.
void setID(const StringView &id)
Sets the translation identifier.
String m_language_name
The human-readable name of the language.
static String DefaultReadableLabel(const UUID &text_string)
Generates a default human-readable label from a UUID.
Translator(const File &settings_file)
Constructs a Translator from a settings file on disk.
bool m_has_loaded_language
Whether the language data has been loaded from disk.
File activeTranslatorFile() const
Returns the file path of the currently active translator file.
INIFactory m_language_ini
The INI factory managing the language translation file.
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Contains logic for translating a string into a defined language.
String readable_id
Human-readable identifier for the translation entry.
String translation
The translated text in the target language.
String english_string
The original English text to be translated.