company logo

Text cache

The text cache has been provided for optimizing fixed text translation. Fixed text translation is based on text entries stored in the resource database or dictionary ( DSC_TextEntry extent). A text entry is identified by a text key up to 80 bytes, which is taken from the first 80 bytes passed to the translate function (or less). When the text entry does not yet exist in the cache, it will be loaded from the resource database(s). When no such text entry exists, an empty text entry with the current key is stored to the text cache.

Any number of text databases may be registered for an application. When looking up text entries, the text cache checks the registered text databases in reverse order, i.e. the last text database registered for the application is checked first. When a text entry has been found in one of the databases, searching stops regardless whether the text entry found provides text for the required language or not.

The text cache is an application resource, i.e. it may be shared by a number of threads in multiple thread applications.

Using text cache

In order to translate fixed texts in multilingual applications, text constants used in a program are used as key for the text entry collection. by calling the odaba :: Application ::translate() function, a translated text version for the current application language may be provided. As long as no text entry has been created for the current application language in the resource database, the translate() function returns the value passed as parameter. When a text entry has been provided and a translation for the current application language has been found, the translated text will be returned, the passed text otherwise.

Text entries are searched by the text entry key consisting of the first 80 characters (or less) of the fixed text passed to the translate() function. Once, a fixed text had been looked up, it will be stored in the text cache in order to improve performance.

The default text is the value that had been set in the DSC_Language option. The default translation language might be changed by calling odaba :: Application ::translationLanguage() .

C++: odaba::Application::translate("This is an important message");

OSI: Translate("This is an important message");

Notes:

Since the text entry key is limited to 80 characters (local encoding), different fixed text values should differ in the first 80 bytes. Fixed text values are limited to 256 characters.

Register text database

Text entries are searched in one or more databases. In order to register a text database for the text cache, it has to be added to the application. When opening a data source ( odaba::DataSource ), the data source dictionary and resource database (when defined explicitly) are registered automatically to the text cache (dictionary first). Other databases may be registered for the application ( odaba :: Application ::registerTextDatabase() ). One may also unregister text databases( odaba :: Application ::unregisterTextDatabase() ). Since text entries are cached, one should reset the text cache after register or unregister text databases ( odaba :: Application ::resetTextCache() ).

Notes:

Text databases are registered by name (database path). In case that database had been opened several times, is can be registered as text database ones, only. The database handle registered is the lat one, that had been registered.

Reset text cache

Especially when testing an application, text entries might be updated. In order to reload updated text entries, the text cache has to be reset ( odaba :: Application ::resetTextCache() ). Text cache should also be reset when text databases had been registered or unregistered.

Implicitly registered text databases

Some text databases are registered implicitly. ODE ( ode90 or code ) applications, i.e. applications based on the GUI framework, will automatically register the system dictionary (defined as DICTIONARY in the SYSTEM section) and the application dictionary ( RESDB ) to the text cache. When opening a data source ( DataSource ::open() ), databases assigned to DICTIONARY and RESOURCES (when being defined), are implicitly registered