Open Reality Reference Guide
 
Loading...
Searching...
No Matches
fbmultilang.h File Reference

Contains language and localization related functionalities. More...

#include <kaydaradef.h>
#include <fbsdk/fbtypes.h>

Go to the source code of this file.

Classes

class  FBMultiLangManager
 Language manager. More...
 

Macros

#define FBSDK_DLL   K_DLLIMPORT
 Be sure that FBSDK_DLL is defined only once...
 

Functions

 FB_FORWARD (FBPlug)
 
K_DLLIMPORT const char * FBGetMultiLangText (FBPlug *pContext, const char *pKey, bool pFlagReturnKey=false)
 Name lookup in the context of an object.
 
K_DLLIMPORT const char * FBGetMultiLangText (const char *pContext, const char *pKey, bool pFlagReturnKey=false)
 Name lookup in a user defined context context.
 
 FB_FORWARD (FBMultiLangManager)
 

Detailed Description

Contains language and localization related functionalities.

Definition in file fbmultilang.h.

Macro Definition Documentation

◆ FBSDK_DLL

#define FBSDK_DLL   K_DLLIMPORT

Be sure that FBSDK_DLL is defined only once...

Definition at line 51 of file fbmultilang.h.

Function Documentation

◆ FBGetMultiLangText() [1/2]

K_DLLIMPORT const char * FBGetMultiLangText ( const char *  pContext,
const char *  pKey,
bool  pFlagReturnKey = false 
)

Name lookup in a user defined context context.

This version of the function is a little less useful as the context string, if not empty, will usually refer to internal class names of objects which is not easily available to the outside world.

As a general rule, an SDK object whose class is 'FBObject' will be wrapping an internal object of class 'KObject'. For example an 'FBCamera' is a wrapper around a 'KCamera' object. Similarily an 'FBConstraint' wll wrap a 'KConstraint'. This pattern is not universal and may differ at times, so it will not always be applicable. There are also cases where an 'FB' objects has no corresponding 'K' object, such as in the case of an 'FBSystem' object.

On lookup there are potentially two searches made: a first one, using the context if one was provided. Should the first search fail, a second search will be done without using the context.

Again the lookup result is dependant on the current language selected, as indicated by the class FBMultiLangManager.

Parameters
pContextString which dictates the context of the lookup.
pKeyString to look up.
pFlagReturnKeyShould the lookup fail, will return the key instead of an empty string.
Returns
The corresponding string if the lookup was succesfull. If not will return an empty string if pFlagReturnKey was false. Otherwise will return the key string.

The following sample code shows 2 cases that do not use context, and 2 cases that are using a context which are internal class names.

Python sample code:

from pyfbsdk import *
print FBGetMultiLangText( '', 'CharacterExtension' ) # Will return 'Character Extension'.
print FBGetMultiLangText( '', 'TranslationMax' ) # Will return 'Max Freedom'.
print FBGetMultiLangText( 'KConstraintUIName', 'Parent-Child' ) # Will return 'Parent/Child'.
print FBGetMultiLangText( 'KCamera', 'FieldOfView' ) # Will return 'Field Of View'.
K_DLLIMPORT const char * FBGetMultiLangText(FBPlug *pContext, const char *pKey, bool pFlagReturnKey=false)
Name lookup in the context of an object.

C++ sample code:

// Will return 'Character Extension'.
FBTrace( "%s\n", FBGetMultiLangText( "", "CharacterExtension" ));
// Will return 'Max Freedom'.
FBTrace( "%s\n", FBGetMultiLangText( "", "TranslationMax" ));
// Will return 'Parent/Child'.
FBTrace( "%s\n", FBGetMultiLangText( "KConstraintUIName", "Parent-Child" ));
// Will return 'Field Of View'.
FBTrace( "%s\n", FBGetMultiLangText( "KCamera", "FieldOfView" ));
K_DLLIMPORT void FBTrace(const char *pFormatString,...)
This function prints useful debugging strings in the console with kFBNORMAL_TRACE output detailed lev...

◆ FBGetMultiLangText() [2/2]

K_DLLIMPORT const char * FBGetMultiLangText ( FBPlug pContext,
const char *  pKey,
bool  pFlagReturnKey = false 
)

Name lookup in the context of an object.

Most application objects have an internal name which differs from the name shown by the GUI. This will often be the case for the names of an object's properties.

The way that support for multiple languages has been implemented is using conversion tables that will map the internal name to a localized name. Since the same internal name might mean different things for different objects, we can provide a context to help the lookup process.

In this case, the context is a class object instance. When the lookup fails within a context, we sucessively try a lookup using the parent classes in the object hierarchy.

It is important to note that for given property, it only knows about its internal name. The localized name is not attached to the property object itself as it resides elsewhere, in a lookup table. This is also the case for any other application object.

The lookup table used to find the localized, or GUI name, of an object is dependent on the current language used. This information is available via the class FBMultiLangManager, which can indicate which language are availables and provides methode to query and change the current language.

Parameters
pContextObject which dictates the context of the lookup.
pKeyString to look up.
pFlagReturnKeyShould the lookup fail, will return the key instead of an empty string.
Returns
The corresponding string if the lookup was succesfull. If not will return an empty string if pFlagReturnKey was false. Otherwise will return the key string.

Python sample code:

from pyfbsdk import *
# Let's pick the first camera present in the system.
lCamera = FBSystem().Cameras[0]
# We know that cameras have a property named 'LockMode'.
lPropInternalName = lCamera.PropertyList.Find( 'LockMode' )
if lPropInternalName:
print 'Actual property name, as defined internally: "%s"' % lPropInternalName.GetName()
print 'Property name as shown by the GUI: "%s"' % FBGetMultiLangText( lCamera, lPropInternalName.GetName())
lPropLocalizedName = lCamera.PropertyList.Find( FBGetMultiLangText( lCamera, lPropInternalName.GetName()))
if lPropLocalizedName and lPropInternalName.GetName() == lPropLocalizedName.GetName():
print 'Found the same property using both the internal (%s) and localized name (%s).' % (
lPropLocalizedName.GetName(),
FBGetMultiLangText( lCamera, lPropInternalName.GetName()))
FBPropertyManager PropertyList
Read Only Property: Manages all of the properties for the component.
const char * GetName()
Get the property's name.
FBProperty * Find(const char *pPropertyName, bool pMultilangLookup=true)
Find a property, based on its name.
Provides access to the underlying system, and the MotionBuilder scene.
Definition fbsystem.h:157

C++ sample code:

// Let's pick the first camera present in the system.
FBCamera* lCamera = FBSystem().Cameras[0];
// We know that cameras have a property named 'LockMode'.
FBProperty* lPropInternalName = lCamera->PropertyList.Find( "LockMode" );
if( lPropInternalName )
{
FBTrace( "Actual property name, as defined internally: '%s'\n", lPropInternalName->GetName());
FBTrace( "Property name as shown by the GUI: '%s'\n", FBGetMultiLangText( lCamera, lPropInternalName->GetName()));
FBProperty* lPropLocalizedName = lCamera->PropertyList.Find( FBGetMultiLangText( lCamera, lPropInternalName->GetName()));
if( lPropLocalizedName && stricmp( lPropInternalName->GetName(), lPropLocalizedName->GetName()) == 0 )
{
FBTrace( "Found the same property using both the internal (%s) and localized name (%s).\n",
lPropLocalizedName->GetName(),
FBGetMultiLangText( lCamera, lPropInternalName->GetName()));
}
}
Creates custom cameras and manages system cameras.
Definition fbcamera.h:206
Property: Base property class.