Kanzi Graphics Engine
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
kzu_localization_manager.h File Reference

Localization manager. More...

Typedefs

typedef kzsError(* KzuLocalizationUpdatedCallback )(struct KzuLocalizationManager *localizationManager, enum KzuLocalizationUpdateReason reason, void *userData)
 Callback function for receiving notifications when anything in the localization manager has changed. More...
 

Functions

kzsError kzuLocalizationManagerCreate (const struct KzcMemoryManager *memoryManager, struct KzuLocalizationManager **out_localizationManager)
 Creates a Localization manager. More...
 
kzsError kzuLocalizationManagerDelete (struct KzuLocalizationManager *localizationManager)
 Deletes a Localization manager. More...
 
kzsError kzuLocalizationManagerSetActiveLocale (struct KzuLocalizationManager *localizationManager, kzString activeLocale)
 Sets the active locale of the Localization manager. More...
 
kzString kzuLocalizationManagerGetActiveLocale (const struct KzuLocalizationManager *localizationManager)
 Gets the active locale of the Localization manager. More...
 
kzsError kzuLocalizationManagerGetAvailableLocales (const struct KzuLocalizationManager *localizationManager, struct KzcDynamicArray **out_availableLocales)
 Gets all available locales registered to the Localization manager. More...
 
kzBool kzuLocalizationManagerHasLocale (const struct KzuLocalizationManager *localizationManager, kzString locale)
 Checks if the given locale has been registered to the Localization manager. More...
 
kzBool kzuLocalizationManagerIsResourceURLLocalized (const struct KzuLocalizationManager *localizationManager, kzString resourceURL)
 Checks if the given resource URL has been localized with the active locale. More...
 
kzBool kzuLocalizationManagerIsResourceURLLocalizedForLocale (const struct KzuLocalizationManager *localizationManager, kzString locale, kzString resourceURL)
 Checks if the given resource URL has been localized with the given locale. More...
 
kzString kzuLocalizationManagerGetLocalizedResourceURL (const struct KzuLocalizationManager *localizationManager, kzString resourceURL)
 Returns a localized resource URL for the given resource URL using the currently active locale. More...
 
kzString kzuLocalizationManagerGetLocalizedResourceURLForLocale (const struct KzuLocalizationManager *localizationManager, kzString locale, kzString resourceURL)
 Returns a localized resource URL for the given resource URL using the specified locale. More...
 
kzsError kzuLocalizationManagerAddListener (struct KzuLocalizationManager *localizationManager, KzuLocalizationUpdatedCallback callback, void *userData)
 Adds a listener to receive notifications about localization changes. More...
 
kzsError kzuLocalizationManagerRemoveListener (struct KzuLocalizationManager *localizationManager, KzuLocalizationUpdatedCallback callback, void *userData)
 Removes a listener receiving notifications about localization changes. More...
 
kzsError kzuLocalizationManagerAddLocale (struct KzuLocalizationManager *localizationManager, kzString locale)
 Adds a locale to the Localization manager. More...
 
kzsError kzuLocalizationManagerRemoveLocale (struct KzuLocalizationManager *localizationManager, kzString locale)
 Removes a locale from the Localization manager. More...
 
kzsError kzuLocalizationManagerAddLocalizedResourceURL (struct KzuLocalizationManager *localizationManager, kzString locale, kzString resourceURL, kzString localizedResourceURL)
 Adds a localized resource URL to the Localization manager localization table. More...
 
kzsError kzuLocalizationManagerRemoveLocalizedResourceURL (struct KzuLocalizationManager *localizationManager, kzString locale, kzString resourceURL)
 Removes a localized resource URL from the Localization manager localization table. More...
 
kzsError kzuLocalizationManagerUpdateTable (struct KzuLocalizationManager *localizationManager, kzString locale)
 Updates the localization table for the given locale. More...
 
kzsError kzuLocalizationManagerUpdateAllTables (struct KzuLocalizationManager *localizationManager)
 Updates the localization tables for all locales registered to the Localization manager. More...
 
kzBool kzuLocalizationManagerIsComplexScriptSupported (const struct KzuLocalizationManager *localizationManager)
 Returns whether complex script support is enabled in the active locale. More...
 
kzBool kzuLocalizationManagerIsComplexScriptSupportedForLocale (const struct KzuLocalizationManager *localizationManager, kzString locale)
 Returns whether complex script support is enabled in the given locale. More...
 
kzsError kzuLocalizationManagerSetComplexScriptSupported (struct KzuLocalizationManager *localizationManager, kzString locale, kzBool complexScriptSupported)
 Sets if complex script support is enabled or not for the given locale. More...
 
kzsError kzuLocalizationManagerLoadLocalizationTableFromKZB (struct KzuLocalizationManager *localizationManager, struct KzcInputStream *inputStream, const struct KzuBinaryFileInfo *file)
 Loads a localization table from KZB to the Localization manager. More...
 
kzsError kzuLocalizationManagerLoadLocaleFromKZB (struct KzuLocalizationManager *localizationManager, struct KzcInputStream *inputStream, const struct KzuBinaryFileInfo *file)
 Loads a locale from KZB to the Localization manager. More...
 

Detailed Description

Localization manager.

Copyright 2008-2019 by Rightware. All rights reserved.

Typedef Documentation

typedef kzsError(* KzuLocalizationUpdatedCallback)(struct KzuLocalizationManager *localizationManager, enum KzuLocalizationUpdateReason reason, void *userData)

Callback function for receiving notifications when anything in the localization manager has changed.

Function Documentation

kzsError kzuLocalizationManagerCreate ( const struct KzcMemoryManager memoryManager,
struct KzuLocalizationManager **  out_localizationManager 
)

Creates a Localization manager.

The initial active locale is set to KZ_NULL.

Parameters
memoryManagerMemory manager to use for creating the Localization manager.
out_localizationManagerNewly created Localization manager, which the caller must delete with kzuLocalizationManagerDelete().
kzsError kzuLocalizationManagerDelete ( struct KzuLocalizationManager localizationManager)

Deletes a Localization manager.

kzsError kzuLocalizationManagerSetActiveLocale ( struct KzuLocalizationManager localizationManager,
kzString  activeLocale 
)

Sets the active locale of the Localization manager.

Parameters
activeLocaleThe new locale identifier. If KZ_NULL, all resource queries return the non-translated URL as if the resource has not been localized.
kzString kzuLocalizationManagerGetActiveLocale ( const struct KzuLocalizationManager localizationManager)

Gets the active locale of the Localization manager.

Returns
The active locale of the Localization manager or KZ_NULL if no locale has been set.
kzsError kzuLocalizationManagerGetAvailableLocales ( const struct KzuLocalizationManager localizationManager,
struct KzcDynamicArray **  out_availableLocales 
)

Gets all available locales registered to the Localization manager.

Parameters
out_availableLocalesA list of names of kzString type. The returned dynamic array must be freed by the caller using kzcDynamicArrayDelete(). The strings in the dynamic array are valid only as long as the locales exist in the localization manager.
kzBool kzuLocalizationManagerHasLocale ( const struct KzuLocalizationManager localizationManager,
kzString  locale 
)

Checks if the given locale has been registered to the Localization manager.

Parameters
localeThe locale to check.
kzBool kzuLocalizationManagerIsResourceURLLocalized ( const struct KzuLocalizationManager localizationManager,
kzString  resourceURL 
)

Checks if the given resource URL has been localized with the active locale.

Parameters
resourceURLThe queried resource URL.
Returns
KZ_TRUE if the resource URL has been localized with the active locale, KZ_FALSE otherwise.
kzBool kzuLocalizationManagerIsResourceURLLocalizedForLocale ( const struct KzuLocalizationManager localizationManager,
kzString  locale,
kzString  resourceURL 
)

Checks if the given resource URL has been localized with the given locale.

Parameters
localeThe locale to use when querying if the resource URL has been localized.
resourceURLThe queried resource URL.
Returns
KZ_TRUE if the resource URL has been localized with the given locale, KZ_FALSE otherwise.
kzString kzuLocalizationManagerGetLocalizedResourceURL ( const struct KzuLocalizationManager localizationManager,
kzString  resourceURL 
)

Returns a localized resource URL for the given resource URL using the currently active locale.

Parameters
resourceURLThe queried resource URL.
Returns
Returns a localized version of the resource URL or resourceURL as it is if it has not been localized with the active locale.
kzString kzuLocalizationManagerGetLocalizedResourceURLForLocale ( const struct KzuLocalizationManager localizationManager,
kzString  locale,
kzString  resourceURL 
)

Returns a localized resource URL for the given resource URL using the specified locale.

Parameters
localeThe locale to use when querying the localized version of the resource URL.
resourceURLThe queried resource URL.
Returns
Returns a localized version of the resource URL or resourceURL as it is if it has not been localized with the given locale.
kzsError kzuLocalizationManagerAddListener ( struct KzuLocalizationManager localizationManager,
KzuLocalizationUpdatedCallback  callback,
void userData 
)

Adds a listener to receive notifications about localization changes.

kzsError kzuLocalizationManagerRemoveListener ( struct KzuLocalizationManager localizationManager,
KzuLocalizationUpdatedCallback  callback,
void userData 
)

Removes a listener receiving notifications about localization changes.

kzsError kzuLocalizationManagerAddLocale ( struct KzuLocalizationManager localizationManager,
kzString  locale 
)

Adds a locale to the Localization manager.

Initially no localization entries for that locale will be present in the localization table. This function does nothing if the locale already exists in the Localization manager.

Parameters
localeLocale to be added.
kzsError kzuLocalizationManagerRemoveLocale ( struct KzuLocalizationManager localizationManager,
kzString  locale 
)

Removes a locale from the Localization manager.

All localization entries for that locale are also removed from the localization table.

Parameters
localeLocale to be removed.
Returns
Throws an error if the given locale is not registered to the Localization manager.
kzsError kzuLocalizationManagerAddLocalizedResourceURL ( struct KzuLocalizationManager localizationManager,
kzString  locale,
kzString  resourceURL,
kzString  localizedResourceURL 
)

Adds a localized resource URL to the Localization manager localization table.

This function also registers the locale if it has not yet been registered to the Localization manager. This function overwrites any previously added localization entry with the same locale and resourceURL. Call ::kzuLocalizationUpdateTable or ::kzuLocalizationUpdateAllTables after all localized URLs have been added to make the changes effective.

Parameters
localeLocale of the localized resource.
resourceURLNon-localized resource URL.
localizedResourceURLLocalized resource URL.
kzsError kzuLocalizationManagerRemoveLocalizedResourceURL ( struct KzuLocalizationManager localizationManager,
kzString  locale,
kzString  resourceURL 
)

Removes a localized resource URL from the Localization manager localization table.

Call ::kzuLocalizationUpdateTable or ::kzuLocalizationUpdateAllTables after all localized URLs have been removed to make the changes effective.

Parameters
localeLocale of the localized resource.
resourceURLNon-localized resource URL.
Returns
Throws an error if the resource URL has not been localized for the given locale or the locale has not been registered to the Localization manager.
kzsError kzuLocalizationManagerUpdateTable ( struct KzuLocalizationManager localizationManager,
kzString  locale 
)

Updates the localization table for the given locale.

This function must be called after adding or removing localized resources to make the changes effective.

kzsError kzuLocalizationManagerUpdateAllTables ( struct KzuLocalizationManager localizationManager)

Updates the localization tables for all locales registered to the Localization manager.

This function must be called after adding or removing localized resources to make the changes effective.

kzBool kzuLocalizationManagerIsComplexScriptSupported ( const struct KzuLocalizationManager localizationManager)

Returns whether complex script support is enabled in the active locale.

Complex script support enables correct layout for bidirectional text and languages that require ligatures.

Returns
Returns whether support for right-to-left text and languages that require ligatures is enabled in the active locale.
kzBool kzuLocalizationManagerIsComplexScriptSupportedForLocale ( const struct KzuLocalizationManager localizationManager,
kzString  locale 
)

Returns whether complex script support is enabled in the given locale.

Complex script support enables correct layout for bidirectional text and languages that require ligatures.

Parameters
localeThe locale to query for complex script support.
Returns
Returns whether support for right-to-left text and languages that require ligatures is enabled in the given locale. If locale is KZ_NULL, returns complex script support for default locale.
kzsError kzuLocalizationManagerSetComplexScriptSupported ( struct KzuLocalizationManager localizationManager,
kzString  locale,
kzBool  complexScriptSupported 
)

Sets if complex script support is enabled or not for the given locale.

This function also registers the locale if it has not yet been registered to the Localization manager.

Parameters
localeThe locale to set the complex script support setting for. If locale is KZ_NULL, the setting is set for the default locale.
kzsError kzuLocalizationManagerLoadLocalizationTableFromKZB ( struct KzuLocalizationManager localizationManager,
struct KzcInputStream inputStream,
const struct KzuBinaryFileInfo file 
)

Loads a localization table from KZB to the Localization manager.

This function is for internal use only.

kzsError kzuLocalizationManagerLoadLocaleFromKZB ( struct KzuLocalizationManager localizationManager,
struct KzcInputStream inputStream,
const struct KzuBinaryFileInfo file 
)

Loads a locale from KZB to the Localization manager.

This function is for internal use only.