-
-
Notifications
You must be signed in to change notification settings - Fork 5
I18N Module
The i18n module provides tools for implementing i18n and m17n features.
To enable the i18n module, update your uvproj.yaml
so that the i18n
key under enabled-modules
is set to true like this:
name: "MyProject"
version: "1.0.0.0"
engine-version: "1.0.0.0"
enabled-modules:
i18n: true
Then, regenerate the modules cache by running the following command:
user $ ./UVKBuildTool --generate <project directory>
After that, refresh your CMake project with cmake ..
!
Next, in your source file, include the Modules.hpp
header in your components like this:
#include <Modules/Modules.hpp>
The entire module is flagged as event safe at any time
.
The module is based on the UntitledI18N library. You can find out more about the translation format here.
All translations are stored under the Config/Translations/
directory. When the module is enabled, translations are loaded automatically with the default locale being set to en_US
.
The i18n module is under the I18N
class. It looks like this:
class I18N
{
public:
static void setCurrentLocale(UI18N::LanguageCodes locale) noexcept;
static ui18nstring get(const char* id, const std::vector<ui18nstring>& positionalArgs = {}, const ui18nmap<ui18nstring, ui18nstring>& args = {}) noexcept;
static void pushVariable(const ui18nstring& name, const ui18nstring& val) noexcept;
static const std::vector<UI18N::LanguageCodes>& getExistingLocales() noexcept;
static UI18N::TranslationEngine& getEngine() noexcept;
};
The functions are almost identical to the ones provided by the TranslationEngine
class in the underlying UntitledI18N library. More info here.
We also provide a C API that looks like this:
const char* UImGui_I18N_get(const char* id, char** pargv, size_t pargc, UI18N_Pair* argv, size_t argc);
void UImGui_I18N_pushVariable(const char* name, const char* val);
void UImGui_I18N_setCurrentLocale(UI18N_LanguageCodes locale);
const UI18N_LanguageCodes* UImGui_I18N_getExistingLocales(size_t* size);
The functions are also identical to the C version of the TranslationEngine
API. More info here.
To check for the module at compile time, use the UIMGUI_I18N_MODULE_ENABLED
macro.
Runtime checking can be done using the i18n
member of the ModuleSettings
struct. More info can be found
here.
This project is supported by all the people who joined our discord server and became beta testers. If you want to join the discord you can click here.
- Home
- Beginner content
- Install guide
- Creating and using the UI components
- The Instance
- The Init Info struct
- Textures
- Logging
- Unicode support
- Additional features
- Client-side bar
- Custom type definitions
- Memory management
- C API development
- Config files and Folders
- Interfaces
- Internal Event safety
- Customising the build system
- Modules system
- Collaborating with others
- Advanced content
- Developer and contributor resources
- Misc