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... |
|
Defines |
|
#define | FBSDK_DLL K_DLLIMPORT |
Be sure that FBSDK_DLL is defined only
once... |
|
Functions |
|
FB_FORWARD (FBPlug) | |
FBSDK_DLL const char * | FBGetMultiLangText (const HFBPlug pContext, const char *pKey, bool pFlagReturnKey=false) |
Name lookup in the context of an object.
|
|
FBSDK_DLL const char * | FBGetMultiLangText (const char *pContext, const char *pKey, bool pFlagReturnKey=false) |
Name lookup in a user defined context
context. |
|
FB_FORWARD (FBMultiLangManager) |
Contains language and localization related functionalities.
Definition in file fbmultilang.h.
#define FBSDK_DLL K_DLLIMPORT |
Be sure that FBSDK_DLL is defined only once...
Definition at line 51 of file fbmultilang.h.
FB_FORWARD | ( | FBPlug | ) |
FBSDK_DLL const char* FBGetMultiLangText | ( | const HFBPlug | 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.
pContext | Object which dictates the context of the lookup. |
pKey | String to look up. |
pFlagReturnKey | Should the lookup fail, will return the key instead of an empty 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()))
C++ sample code:
// Let's pick the first camera present in the system. HFBCamera lCamera = FBSystem().Cameras[0]; // We know that cameras have a property named 'LockMode'. HFBProperty 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())); HFBProperty 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())); } }
FBSDK_DLL 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.
pContext | String which dictates the context of the lookup. |
pKey | String to look up. |
pFlagReturnKey | Should the lookup fail, will return the key instead of an empty 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'.
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" ));
FB_FORWARD | ( | FBMultiLangManager | ) |