Data Descriptions store descriptions of attributes. This includes the translated names of these attributes in various languages. Using maxon::Resource and maxon::LanguageInterface it is easily possible to access such translated strings.
The maxon::Resource class gives access to the supported languages:
// get current language for later comparison const maxon::LanguageRef currentLanguage = maxon::Resource::GetCurrentLanguage ();
// get all languages const auto languages = maxon::Resource::GetAllLanguages () iferr_return ;
// loop through all languages for (const maxon ::LanguageRef& language : languages) { // print language name DiagnosticOutput ( "Language: @" , language.GetName());
// check if language is the current language if (currentLanguage == language) DiagnosticOutput ( "--> Current Language" ); }
A localized string of the current language can be obtained with:
// prepare database and attribute IDs const maxon::Id databaseID { "net.maxonexample.description" }; maxon::InternedId attributeID; attributeID. Init ( "net.maxonexample.description.option" ) iferr_return ;
// get string const maxon::String localizedString = maxon::Resource::LoadResourceString (databaseID, attributeID); DiagnosticOutput ( "Localized String: \"@\"" , localizedString);
The properties of a language object are accessed with:
// get current language const maxon::LanguageRef language = maxon::Resource::GetCurrentLanguage ();
// get language settings const maxon::String languageName = language.GetName(); const maxon::Id languageId = language.GetIdentifier(); DiagnosticOutput ( "Language: \"@\" (@)" , languageName, languageId);
A localized string of a given language can be obtained with:
// prepare database and attribute IDs const maxon::Id database( "net.maxonexample.description" ); maxon::InternedId attribute; 属性。 Init ( "net.maxonexample.description.option" ) iferr_return ;
// get string const maxon::LanguageRef language = maxon::Resource::GetCurrentLanguage (); const maxon::String localizedString = language.LoadResourceString(database, attribute); DiagnosticOutput ( "Localized String: \"@\"" , localizedString);