Dynamic Language Translation

From Lianjapedia
Jump to: navigation, search

Overview

Dynamic language translation for web and mobile Apps is available from Lianja v5.5, with the option to use Google translate or a custom script.

The example_webapp1 sample App (Lianja Tablet Web UI Demo) included in the distribution demonstrates the new functionality.

Dynamic Language Translation


App Settings

The following App Settings are available in 'General App Configuration' to configure dynamic language translation.

Enable user translate

Set to True to enable user translation in web/mobile/tablet Apps.

When True and Enable google translate or Enable text translator is also True, a flag representing the current language is displayed in the Page Header.

Clicking the flag displays a pulldown list of languages for user selection.

Enable text translator

Set to True to enable text translation in web/mobile/tablet Apps. This enables dynamic language translation of captions in the UI.

See Text Translator for information on defining an App Text Translator Delegate.

Enable google translate

Set to True to enable Google translate in web/mobile/tablet Apps. This enables dynamic language translation of captions in the UI.

When True and Enable user translate is also True, a flag representing the current language is displayed in the Page Header. Clicking the flag displays a pulldown list of languages for user selection.

Lianja.switchLanguage()

The Lianja.switchLanguage(code) system object method is available in the Lianja Web Framework (web, mobile). It switches the applicable UI text to the language code specified.

The language code is the two letter ISO 639-1 code. e.g.

Lianja.switchLanguage("de");

The App must have Enable google translate or Enable text translator set to True.

Custom Translations

The translations can be overridden with custom values using the loadcustomtranslations.rsp script. This is located in the wwwroot directory.

App specific loadcustomtranslations.rsp scripts can also be created and should be located in the App's directory.

Both the system-wide loadcustomtranslations.rsp and the App specific loadcustomtranslations.rsp are loaded if they exist.

loadcustomtranslations.rsp

<%@ Language=VFP %>
<%
	private data, item
	private lang = _args["LANG"]
	data = array()
 
	// For each word or phrase that needs corrected add a tuple to the data dynamic array.
 
	item = object()
	item.lang = "da"
	item.origtext = "Orders"
	item.newtext  = "Ordrer"
	data[] = item
 
	// Send JSON string to the client
	print_json( data )
 
%>

systranslations System Table

The systranslations system table for storing customized translations will be available in a future release.