Languages and

String Resources

内容表

关于

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.

注意
maxon::Resource::LoadResourceString() and maxon::LanguageInterface::LoadResourceString() access the same data as maxon::DataDescriptionDatabaseInterface::LoadDescription() .

Resources

The maxon::Resource class gives access to the supported languages:

// This example loops through all known languages and prints their names.

// 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:

// This example loads the string for the given attribute in the current language.

// 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:

// This example gets the current language and prints its settings to the console.

// 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:

// This example loads the string for the given attribute in the current language.

// 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);

延伸阅读

static MAXON_METHOD LanguageRef GetCurrentLanguage()
static MAXON_METHOD Result< BaseArray< LanguageRef > > GetAllLanguages()
The maxon namespace contains all declarations of the MAXON API.
定义: c4d_basedocument.h:15
定义: string.h:1197
定义: apibaseid.h:250
#define iferr_return
定义: resultbase.h:1434
#define DiagnosticOutput(formatString,...)
定义: debugdiagnostics.h:166
Result< void > Init(const Id &i)
定义: datatypelib.h:26
static MAXON_METHOD String LoadResourceString(const Id &scope, const InternedId &keyValue)

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1