3ds Max C++ API Reference
MaxSDK::TranslationSupport Namespace Reference

MAXScript scripts are typically written in English, but when MAXScript accesses names from TrackView nodes only localized names are available. More...

Enumerations

enum  ResolutionContext { kTrackViewNodes , kCount }
 The property name resolution context where localized \ English string translation lookup is occurring. More...
 

Functions

CoreExport bool RegisterTranslation (ResolutionContext context, const MCHAR *localizedString, const MCHAR *nonLocalizedString)
 Specifies translation between a localized and non-localized (English) string pair for when MAXScript is performing property resolution. More...
 
CoreExport bool GetLocalizedStrings (ResolutionContext context, const MCHAR *nonLocalizedString, Tab< const MCHAR * > &localizedStrings)
 Retrieves localized translations for a non-localized (English) string. More...
 
CoreExport bool GetNonLocalizedStrings (ResolutionContext context, const MCHAR *localizedString, Tab< const MCHAR * > &nonLocalizedStrings)
 Retrieves non-localized (English) translations for a localized string. More...
 

Detailed Description

MAXScript scripts are typically written in English, but when MAXScript accesses names from TrackView nodes only localized names are available.

By specifying localized and English string pairs using the RegisterTranslation method, MAXScript is able to retrieve the English name corresponding to a localized name to see if it matches the property name or SubAnim name specified by a script. Code that operates on TrackView nodes via ITrackViewNode::AddNode or ITrackViewNode::AddController should register via RegisterTranslation the English name corresponding to the localized name specified in these methods. TrackView nodes persist their names to the scene file, so in order to ensure that the translations are present when loading the scene file, the translations should be registered when the dll is loaded.

For example, if have the following code:

node->AddNode(vp, GetString(IDS_RB_VIDEOPOST), VIDEO_POST_TVNODE_CLASS_ID);
vp->AddController(cont, GetString(IDS_RB_FLOAT), cont->ClassID());
#define VIDEO_POST_TVNODE_CLASS_ID
Definition: tvnode.h:39

The following would be specified:

void RegisterTranslations()
{
GetString(IDS_RB_VIDEOPOST), _T("Video Post"));
GetString(IDS_RB_FLOAT), _T("Float"));
}
@ kTrackViewNodes
Definition: TranslationSupport.h:70
CoreExport bool RegisterTranslation(ResolutionContext context, const MCHAR *localizedString, const MCHAR *nonLocalizedString)
Specifies translation between a localized and non-localized (English) string pair for when MAXScript ...

And then RegisterTranslations() would be called from the DllMain function handling of DLL_PROCESS_ATTACH. For example:

BOOL WINAPI DllMain(HINSTANCE hinstDLL,ULONG fdwReason,LPVOID lpvReserved)
{
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
hInstance = hinstDLL;
DisableThreadLibraryCalls(hInstance);
RegisterTranslations();
break;
}
return (TRUE);
}
UtilExport void UseLanguagePackLocale(HMODULE hMyModule=reinterpret_cast< HMODULE >(&__ImageBase))
Sets the locale for a DLL or thread to match that of the language pack being used at 3ds Max start up...
HINSTANCE hInstance

Enumeration Type Documentation

◆ ResolutionContext

The property name resolution context where localized \ English string translation lookup is occurring.

Enumerator
kTrackViewNodes 
kCount 
69  {
70  kTrackViewNodes, //< Resolving Trackview Node \ Controller names
71  kCount //< the number of contexts
72  };
@ kCount
Definition: TranslationSupport.h:71

Function Documentation

◆ RegisterTranslation()

CoreExport bool MaxSDK::TranslationSupport::RegisterTranslation ( ResolutionContext  context,
const MCHAR localizedString,
const MCHAR nonLocalizedString 
)

Specifies translation between a localized and non-localized (English) string pair for when MAXScript is performing property resolution.

Parameters
[in]context- The property name resolution context where this translation will be used
[in]localizedString- the localized string
[in]nonLocalizedString- the non-localized (English) string
Returns
- always returns true. A return value is specified so that this method can be used as a static variable initializer, registering translation once. /note The strings are stored in lower case as name resolution in MAXScript is case insensitive when dealing with 3dsMax objects. /note If the localized and non-localized strings are case-insensitive equivalent, the strings are not registered. /note Unique localized \ non-localized string pairs will only be registered once.

◆ GetLocalizedStrings()

CoreExport bool MaxSDK::TranslationSupport::GetLocalizedStrings ( ResolutionContext  context,
const MCHAR nonLocalizedString,
Tab< const MCHAR * > &  localizedStrings 
)

Retrieves localized translations for a non-localized (English) string.

Parameters
[in]context- The property name resolution context
[in]nonLocalizedString- the non-localized (English) string
[out]localizedStrings- an array of the localized strings
Returns
- returns true if localized strings were found, false otherwise. /note This method would not normally be used by 3rd party developers.

◆ GetNonLocalizedStrings()

CoreExport bool MaxSDK::TranslationSupport::GetNonLocalizedStrings ( ResolutionContext  context,
const MCHAR localizedString,
Tab< const MCHAR * > &  nonLocalizedStrings 
)

Retrieves non-localized (English) translations for a localized string.

Parameters
[in]context- The property name resolution context
[in]localizedString- the localized string
[out]nonLocalizedStrings- an array of the non-localized (English) strings
Returns
- returns true if non-localized strings were found, false otherwise.
- returns true if localized strings were found, false otherwise. /note This method would not normally be used by 3rd party developers.