Multilingualism

General Information

Every Intrexx portal can be set up to support multiple languages.

Language and region are represented by ISO 639 and ISO 3166 codes (e.g., en-us for English (United States of America) or en-gb for English (United Kingdom)). These codes form the basis for voice control in portals.

Multilingualism does not only refer to the language-specific display of text, but also to the display of numerical and date values in each country. Colors, too, can be interpreted differently depending on cultural context. Graphics that include text also take on a language-dependent aspect. The direction in which characters are displayed can also be a factor.

When it comes to multilingual portals, there are therefore a number of details to consider and implement—regardless of the technology used. Here you'll find the information you need on this topic.

Language Switching in the Browser

To switch languages in the browser, use the "Language Switcher" control from the "Design" module. The available languages must be enabled in the country settings.

To switch to a different format—one that, for example, displays the date in the appropriate format—use the "Locale Switcher " control from the "Design" module. The available formats must be enabled in the regional settings.

Portal Properties - Country Settings

You can find the country settings in the portal properties, which you can access from the "Portal" main menu. Here, you can configure the portal for international use.

Format

Different formats are used worldwide for displaying dates and numbers. To allow portal users to set the display formats appropriate for their region, so-called formats can be defined.

Available Locations

Here is a list of all the available formats.

Selected Locations

All formats that are enabled for the current portal are listed here.

Select / Deselect Formats

Using the " " arrow buttons, you can move the selected formats to the other list.

Default setting

Select the language for the default setting from the drop-down list in the lower-right corner.

Edit Formats for the Selected Location

Opens a dialog box where you can edit the date and number formats for the currently selected location.

Date Format

Normal / Short / Long

There are three options for displaying the date in the browser: Normal, Short, and Long. To define the format, you can use the patterns from Java's SimpleDateFormat.

Example

In each of the example fields, you'll see a preview of the formatted date.

Start of the week

Set the day here that marks the start of the week.

Legend

Provides information about the meaning of the abbreviations used in the "Normal," "Short," and "Long" fields.

Reset Format Settings

Resets all format settings to the default settings for the selected location.

Time Format

Time Format

To display the time in the browser, you can define the format here using the patterns from Java's SimpleDateFormat.

Example

Here is a preview of the formatted time.

Legend

Provides information about the meaning of the abbreviations used in the "Time Format" field.

Reset Format Settings

Resets all format settings to the default settings for the selected location.

Number Format - Integer Fields

1,000 separator

Select the character you want to use as the thousands separator in your browser.

Example

Here is a preview of the formatted integer.

Reset Format Settings

Resets all format settings to the default settings for the selected location.

Number Format - Number Fields

1,000 separator

Select the character you want to use as the thousands separator in your browser.

Decimal separator

This is where you define the character that the browser uses as the decimal separator before the digits after the decimal point.

Leading zero

Use this option to specify whether a leading zero should be displayed or not.

decimal places

Specify here how many decimal places should be displayed.

Example

Here is a preview of the formatted number.

Reset Format Settings

Resets all format settings to the default settings for the selected location.

Number Format - Currency Fields

1,000 separator

Select the character you want to use as the thousands separator in your browser.

Decimal separator

This is where you define the character that the browser uses as the decimal separator before the digits after the decimal point.

Leading zero

Use this option to specify whether a leading zero should be displayed or not.

decimal places

Specify here how many decimal places should be displayed.

Example

Here is a preview of the formatted number.

Reset Format Settings

Resets all format settings to the default settings for the selected location.

Time Zone

Here, you can assign a time zone to the portal. As a rule, it is the time zone in which the server or the company's headquarters is located. If portal users work in different time zones, you can assign the appropriate time zone to each user in the "Users" module under the user properties. The time zone specified in the portal properties is used if no individual time zone has been entered for a user.

In Intrexx, all date values in the database are stored in UTC (Universal Time Coordinated, also known as GMT, Greenwich Mean Time). To display the time in the browser, the difference between the current time zone and UTC is added or subtracted. The database obtains the time zone setting from the operating system. The time zone of the Intrexx Portal Server and the database should generally be set to the same value. If the database time zone and the Intrexx time zone differ, discrepancies may occur when calculating the local time.

Date values—such as a date of birth—that must not be altered should, when in doubt, be stored as text and, if necessary, formatted for display using Velocity.

Languages

Any number of languages can be enabled for a portal.

Country-Specific Languages

With this setting, localized languages such as "German (Switzerland)" can be used. When you click "OK," the global language constants are updated internally. First, the system checks whether the parent language of the localized language is already available in the portal, e.g., "German." If this is not the case, the system checks whether another localized version of the language is available in the portal, e.g., "German (Austria)." If this is not the case either, the portal's default language is used to supplement the global language constants.

Available Languages

Here is a list of all the languages you can choose from.

Selected Languages

All languages that are enabled for the current portal are listed here.

Moves the currently selected language to the other list.

Changes the order of the languages, e.g., for later selection in the language switcher.

Default Language

The default language is used when language data—such as element titles —is missing in the selected language. The default language is also used as the default setting for newly created users.

Global Texts

In the global texts, all standard texts that appear in the portal can be edited in the various languages.

Meta Tags

Meta tags can be used to provide information to web servers, browsers, and automated search programs on the Internet. Meta tags are HTML tags used to describe the content of an HTML page. Search engines use meta tags to create entries in their databases or to determine the ranking of results in a search list.

INTREXX GmbH assumes no liability for any errors resulting from changes made to meta tags.

Defined Meta Tags

All of the portal's meta tags are listed here.

Remove meta tag

Removes the currently selected meta tag.

Move up / down

Changes the order in which the meta tags are written into the HTML.

Title

The title is entered into the <title> tag on each portal page.

Multilingualism

Opens a dialog box where the title can be edited in the portal languages. A title stored in multiple languages cannot be linked to global language constants in meta tags.

"Language" Column

The portal languages that have been enabled are displayed here.

"Value" column

Enter the desired term in the respective language here.

/ Edit

Opens a dialog box where you can create a new metadata tag and edit existing metadata tags.

Name

Here you can select the most common meta tags. In addition, you can define your own meta tags. Simply enter the name of your meta tag here without selecting an existing meta tag.

Value (monolingual)

Here, you can enter values for single-language meta tags, such as robots=nofollow.

Value (multilingual)

This option allows you to store values in the individual portal languages.

Multilingualism

Opens a dialog box where the title can be edited in the portal languages. A title stored in multiple languages cannot be linked to global language constants in meta tags. Click "OK" to save your changes and close the dialog box.

Layout Assignment

For all layouts

This option generates the meta tag in all portal layouts.

For mobile devices only

The meta tag is generated only on pages that have been optimized for mobile devices.

For selected layouts only

Here, you can enable the meta tag for individual layouts.

"Available Layouts" List

All available layouts are displayed here.

"Selected Layouts" List

This section lists all layouts in which the meta tag is included.

Moves the currently selected layout from one list to the other.

Changes the order of the layouts in the list.

The Importance of Meta Tags

  • Description

    The description must not exceed 200 characters. Enter information here about your company, product, people, or page content.

  • Keywords

    Keywords consist of individual words and should be separated by commas. The keywords summarize the page's content. Choose keywords that a user would search for online to find a page on your portal.

  • Robots (Instructions for Search Engines)

    Here, you specify how the page should be handled by robots that index pages for search engines.

  • noindex

    Prohibition on Indexing the Page

  • index

    Request to index the page

  • follow

    Index the page, follow deeper links

  • nofollow

    Do not index this page; do not follow links

There is a range of other metadata that you can enter. For more details, please refer to the relevant literature on web design or the Internet.

Global Language Constants

All text elements used in the Intrexx standard are defined in the global language constants. You'll also find specific language constants for Intrexx Share here. This allows text that appears multiple times in various applications within a portal to be stored centrally.

Search

Enter a search term here. The term is searched for in the names of the constants and in all translated texts.

Filter

Type

Here, you can filter the list by constants used in JavaScript or Velocity.

Custom / Default

This filter displays only user-defined constants, Intrexx default constants, or both.

Column Name

Displays the name of the language constant.

Column Type

The use of the constant is shown here.

Language Column

The following columns display all text in the respective portal languages.

Filter by language

Click here if you want to hide a language column in the list, such as English.

Create a copy of the language constant

Creates a copy of the currently selected constant.

Remove

Deletes the currently selected user-defined constant. Intrexx standard constants cannot be deleted.

/ Edit Language Constant

Opens a dialog box where you can define a new language constant or edit an existing language constant that is selected in the list.

Name

Enter the name of the language constant here. This name can be used later to access the constant within the respective scope. The name must be unique. If possible, use an English name consisting entirely of uppercase letters, with no special characters or spaces. The name must start with a letter, followed by additional letters, numbers, or an underscore. It is recommended that you specify a namespace to isolate your own constants from the Intrexx default constants. This can be a namespace related to projects or customers.

Type

Here you can specify the scope of a language constant:

The constant is only available in JavaScript

The constant cannot be selected as a title in applications and cannot be used in Velocity. Use as few language constants of this type as possible, since JavaScript always has to be transmitted. Use string constants in JavaScript exclusively for messages in your own validation routines (alert(), prompt(), confirm(), or Intrexx Notifier) or for dynamic output in text view fields. In JavaScript, the currently selected portal language is always used. If, as in the following example, the first key is not found, the search continues using the fallback parameter, if one is available. If the fallback also returns no result, "undefined" is returned.

            // Read application constant
ix.text.i18n.getByApp(p_strAppGuid, p_strKey, p_strKeyFallback);
// Read portal constant
ix.text.i18n.get(p_strKey, p_strKeyFallback);

        

The constant is evaluated as a Velocity expression

The constant is not available in JavaScript, but it is available in Velocity and also in the Groovy context. Constants that are available everywhere can also be used in Groovy. Use constants in Velocity exclusively for page labels. This is the most common use case and should therefore be the first choice. Use in Groovy includes this variant. The language code is specified as an ISO code (de, en, etc.). When accessing application constants, the application's GUID must be specified as a parameter.

            ## Read portal constant 
##(Portal language is used as a criterion)
$I18N.get(p_strKey)

## Read portal constant with default language
$I18N.getByLang(p_strLang, p_strKey)

## Read application constant 
## (Application GUID and constant as parameter)
$I18N.getByApp(p_strAppGuid, p_strKey)

## Read application constant with default language
$I18N.getByAppByLang(p_strAppGuid, p_strLang, p_strKey)

## Example
$I18N.getByAppByLang('3E4..2AF', 'de', 'myKey')

        

The constant is available everywhere

Avoid using this setting as much as possible. This type should be used only if a language constant appears in both of the aforementioned cases. In Velocity, global constants can be accessed as follows:

            $I18N.get("NAME")

        

Application constants can be accessed as follows:

            $I18N.getByApp(" APPGUID", " NAME")

        

In Groovy, multilingual text constants can be used to generate log entries or to create constructs that are, for example, written back to data fields. Constants can also be used for labeling when generating data exports with Groovy (e.g., XML files). The `g_i18n` object is available for this purpose; it is initialized with the context language. If there is no context, the portal's default language is used as a fallback.

            // Read application constant
def app = g_i18n.application("APPLIKATIONS_GUID")
def appConst = app["APPLIKATION_LANGUAGE_CONSTANT"]

// Read application constant with default language
def appde = app.language("ISO_LANGUAGE_CODE")

// Read portal constant
def portalConst = g_i18n["PORTAL_LANGUAGE_CONSTANT"]

// Read portal constant with default language
def portalde = g_i18n.language("ISO_LANGUAGE_CODE")
def portalConst = portalde["PORTAL_LANGUAGE_CONSTANT"]

// Example: Read application constants explicitly in English
def app = g_i18n.application("3F2…E1A")
def appen = app.language("en")
def text1 = appen["CUSTOMER"]
// Example: Read application constant
def app = g_i18n.application("3F2…E1A")
def text2 = app["CUSTOMER"]
// Example: Reading portal constants explicitly in German
def portalde = g_i18n.language("de")
def text3 = portalde["CAL_WEEK"]

// Example: Read out portal constants
def text4 = g_i18n["CAL_WEEK"]

        

Title

Here you can assign a title to the language constant in the various portal languages.

"Language" Column

Here you can see the portal languages.

"Title" column

The title corresponds to the value that the constant has when used in the relevant context (e.g., in Velocity). Enter the desired value here.

Naming Language Constants

Name language constants in a way that makes sense so that you can keep track of how they are used. Various prefixes can be used in the name to make it easier to distinguish between them.

Prefix

Uses for

COM_

General constants that are used in various places, such as for labeling elements on the page or page names

ACTION_

Button Labels

TABLE_

Text in tables, such as the message displayed when no records are found (TABLE_NODATA_) or table titles (TABLE_TITLE_).

OPT_

Texts for labels and information in the system data group

MSG_

Text in Messages via JavaScript

MSG_WARN_

Text in warning messages via JavaScript

MSG_ERROR_

Text in Error Messages via JavaScript

CONFIRM_

Text for the description of notes in audit requirements

The MSG_ constants are unique in that messages can contain a title and a detailed text (Notifier). Distinguish between them by adding a suffix to the end of the constant name:

Suffix

Uses for

_TITLE

Title of the Post

_TEXT

Text of the announcement

When language constants are used for list entries, all information related to these elements should be grouped together in the language constant list. To do this, use a grouping attribute based on the prefix—such as the term ACCESSTYPE, for example. The individual options _ROLE, _GROUP, and _USER were appended accordingly.

COM_ACCESSTYPE_ROLE
COM_ACCESSTYPE_GROUP
COM_ACCESSTYPE_USER

There is no one-size-fits-all approach to naming language constants, as how the constant names are defined depends on the complexity of the application. The naming examples shown above are intended only to provide a starting point.

Language Setting for Portal Manager

You can access this dialog box via the main menu under "Tools / Options. "

Portal Manager's Language

You can set the Portal Manager's language here. The new setting will take effect the next time the Portal Manager is restarted.

Display Language for Multilingual Titles

Here, you can select the language in which multilingual titles are displayed.

Language Localization

When you open an application, a process, or a layout in Portal Manager, the system checks whether titles have been entered for all elements in all portal languages. For example, if you have enabled a new portal language, the titles of elements in that new language will initially be blank. When you open it, a dialog box will appear that allows you to copy the titles from an existing portal language into the empty title fields of the newly activated portal language.

To ensure that the system checks for missing tracks when opening a file, the "Check for missing tracks" setting must be enabled in the respective module via the main menu under "Tools/Options. "

Find and Translate Element Titles

In the "Applications, " "Design," and "Processes" modules, you can search for elements that do not yet have a title in any of the portal languages. You can find information on this topic here.

Exporting and Importing Text and Language Constants

You can find all the information you need about importing and exporting titles and names of application or process elements here.

You can find information on importing and exporting global language constants here.

Multilingual Titles

 

Whenever you see the globe icon for multilingual support in the Intrexx Portal Manager, you have the option to edit titles, descriptions, and the like. to capture in multiple languages.

In applications, you'll find a button to the right of the title in the Properties dialog box for elements. Clicking the small arrow on the right side of this button opens a menu where you can choose whether to use a static title or a title from a constant for the element.

If you select "Title" here , the globe icon will then appear on the button to the left of the small arrow.

If you select "Title from Constant," an "A" will appear on the button.

Static Titles

Click the globe icon to open a dialog box where you can enter a static title in the portal languages that have been configured.

The browser will then display the text entered here, based on the language setting in the portal properties. This also applies when the user changes the language in the browser.

Title from "Constant"

Constants can be used instead of static text for the titles of elements in applications. The browser will then display the text entered under "Constants" according to the language setting in the portal properties. This also applies when the user changes the language in the browser. For information on how to create and edit constants and how to enter multilingual text, see here:

If you have selected "Title from Constant" in the Properties dialog box for elements, the drop-down list for the title will then function like a search.

Simply enter the name of the constant you're looking for and select it from the drop-down list.

Clicking the "A" on the button to the right of the title selection opens the "Global Language Constants" dialog, where you can also search for constants and edit them directly.

Language Switching in Modules

The language in which the titles of elements are displayed in the Portal Manager within each module can be changed using the globe icon in the toolbar.

Portal Menu

For applications that are integrated into the menu structure, you can configure the system so that the application's title is used as the menu item. If the title is already stored in multiple languages there, the values for the respective portal languages will also be adopted. If the "Use application title " setting is disabled, the title for this menu item must be entered in multiple languages here. Multilingual titles can also be defined for all other items, such as menu folders, links, or separators.

You can find more information about the menu structure here.

Layout

Since every portal layout consists of various containers —which are parsed by screen readers, particularly in accessible designs—the multilingual titles of the containers must also be taken into account. You cannot use your own language constants in the layout. The individual elements in the layout use appropriately defined global language constants.

User Settings

In the "Users" module, you can set country-specific settings in the user properties.

The settings here for time zone, language, format, and layout take precedence over the settings specified in the country-specific portal properties.

Applications

In the "Applications" module, the use of language constants in applications is not only useful for multilingual applications—monolingual applications also benefit from the use of these constants. Since text appears repeatedly in many places, it can be changed more quickly using a central constant. INTREXX GmbH therefore recommends developing applications from the ground up based on application constants.

Language Constants in Applications

Unlike global language constants, constants can also be defined directly within applications; these constants are then valid only within that application. Constants for applications can be added, edited, and deleted via the main menu under "Application / Manage Language Constants. " You can find all the information about the settings in the "Manage Language Constants" dialog box here.

Starting with Intrexx version 12.0.0

In applications, you can define both language constants that are valid only within the application and global language constants.

You can find the corresponding dialog box in the properties of application elements. For general information on this topic, see the "Multilingual Titles" section.

If you want to create global language constants, you need the portal permission "Manage Global Language Constants."

In the "Manage Language Constants" dialog, click the small arrow button next to the " " button labeled "New Language Constant" to display a menu where you can choose whether the new constant should apply application-wide or globally. You can create the constant using the dialog box that appears next.

Constants for applications can be added, edited, and deleted via the main menu under "Application / Manage Language Constants. "

Options - Language Constants

You can access the optional settings for language constants and titles via the main menu under "Tools / Options / Applications / Language Constants and Titles. "

Constant Type Upon Creation

Here, you can specify which type is initially assigned to a newly created language constant.

Initial Award of the Title

Here, you can specify what type of title should be assigned to elements that are newly created in the Application Designer.

Pre-fill the title field with a default title

The title is taken from the language constant DEFAULT_CTRL_<control type> for the respective element. In the browser, the title is displayed in the portal's current language setting. This setting also applies the title to data fields and data groups.

Pre-fill the title field with a prefix pattern

When creating elements, this setting sets the "Title from Constant " option and fills the title field with the pattern defined here. This specification can also be supplemented with the constant name.

Leave the title field blank initially, and when exiting the dialog

  • Leave the field blank

    The title field remains blank when the user exits the dialog box.

  • display a warning

    If the title field is empty, a corresponding message will appear when the user closes the dialog box.

  • assign a default title

    The title is taken from the language constant DEFAULT_CTRL_<control type> if the title field is empty when the dialog is closed.

Multilingual Titles of Elements

Click here to learn how to enter element titles in multiple languages.

Multilingual list entries

Regarding the elements

Custom values can be selected as the source for the list in the element.

Clicking "Edit" on opens the dialog for editing the list entries.

Instead of a static displayed value, constants can also be used here. To do this, click the small arrow to the right of the globe. You can find out how to select a constant here. In this case, the value displayed from the constant and the stored value must be identical.

Multilingual Datasets

To learn how to enter data records in different languages and display them in the correct language based on the portal's language settings, see the Tips & Tricks article "Multilingual Data Records. "

Multilingual Data with a Dual Primary Key

Multilingual data can be stored in a data group using a dual primary key. It consists of a key and an ISO language code. For tax tables, such as the "Status" table, the key should be a descriptive string. For other data, a GUID should be used.

For the second primary key, a new data field titled "Language" is created before the application is published.

On the "Expert" tab, set the "primarykey" expert attribute to "Yes."

When new records are created, both primary keys must be populated with values to prevent errors in data processing. To do this, the "Language" data field can be linked to an input field in the hidden area. The input field is pre-populated with the current portal language via its binding.

A common scenario involves using multilingual master data—such as statuses or categories—via a reference in transaction records. If a reference to a data group with two primary keys is created, the session variable "Language" must be assigned to the language key. The other primary key is left set to "Created automatically."

Intrexx now always returns the corresponding language text in the browser based on the reference.

Multilingual Emails

Email to a single recipient

When a user sends an email, their language setting can be determined through a process. The process can then apply the identified language to the email to be sent as part of an email campaign.

The subject line can be defined by translating the language-specific subject line accordingly. To customize the language settings, you can use a Groovy script to determine the language before executing the email action and write it to the processing context to use it to control the email action.

            // Language of the current user
def l_strLanguage = Locale.forLanguageTag(g_language).getDisplayLanguage(new Locale(g_language))

// Language of any user 
// (via its GUID and the user object)
def l_objUser = g_om.getUser(l_strUserGuid)
def l_strLanguage = objUser.getDefaultLanguage()

// Putting language into the processing context
g_sharedState.maillanguage = strLanguage

        

In the properties dialog for the email action, on the "Expert" tab, you can add the "language" parameter and pass the language determined from the processing context as the value using "urn.sharedState.maillanguage."

The subject line can also be defined using a language constant. To do this, the content of the language constant is retrieved using the appropriate Groovy method, specifying the language that was previously determined.

            
// Determine subject from language constant and place in processing context 

g_sharedState.subject = g_i18n.application("APP_GUID").language(l_strLanguage)["MYMAILSUBJECT"]

        

The value from the processing context is then inserted into the static, language-independent subject line of the email action using "urn.sharedState.subject."

If the email is also sent via CC and BCC to one recipient in each of the different languages, this procedure cannot be used. In this case, it would be necessary to handle them separately, with dedicated email campaigns for each one in the process chain. The message text could also be determined in the preceding Groovy action and placed in the processing context. The processing context can then be read in Velocity, and the email body can be generated from it.

Starting with Intrexx version 12.2.0

Starting with Intrexx version 12.2.0, the Email Action configuration includes a Language tab where you can set the language for the email's subject and body. You can find all the information here: Email Campaign.

Email to the mailing list

There are two ways to handle multilingualism when sending emails to a distribution list:

  • An email campaign is created for each language, in which recipients are selected based on their language preference.

  • The email is generated using a Groovy script that takes into account the recipient's language. Here, however, you have to construct the body of the message yourself.

A possible basic structure is shown below. However, in this case, only user objects may be specified as recipients via the distribution list.

            import de.uplanet.lucy.util.TextUtil
import de.uplanet.lucy.server.mail.GroovyMailBuilder
import de.uplanet.lucy.server.mail.MailUtil
import de.uplanet.lucy.server.portalserver.PortalServerPath
import de.uplanet.lucy.server.composer.UrlBuilder

// Contents of a distribution list (GUIDs of recipients)
def l_strRecipients = g_record["640...DAC"].value
def l_aReceipients = TextUtil.stringToList(strRecipients)

aReceipients.each {
  def strEmail = g_dbQuery.executeAndGetScalarStringValue(conn, "SELECT
  STRMAILBIZ FROM VBLUSER WHERE STRGUID = ?", null) {
    setString(1, it)
  }
  if(strEmail != null && strEmail != "")
  {	
    def mail = new GroovyMailBuilder().composeMail {
	  headers = [
		"X-IX-Share": "intrexx-share-notification",
	]

	from        = MailUtil.getDefaultSenderAddress()
	to          = strEmail
	subject     = l_mailHelper.getMailTitle()
	contentType = "text/html; charset=UTF-8"

	body << """<html>  … </html>"""
    }
    mail.drop()
  }
}

        

Language Switches

By using language constants, the use of language switches in program code can be largely avoided. For special cases, however, the following constructs may still be useful. To implement a language switch in JavaScript, you must first determine the portal's current language using the oHtmlRoot object.

            var l_lang = oHtmlRoot.oUp.oFormatInfo.lang;

switch(l_lang)
{
  case "de":
       // Code for german language
       break;
  case "en":
       // Code for english language
       break;
  :

  default:
       // Fallback if language is missing (default language of the portal)
}

if(l_lang == "de")
{
  // Code for german language
}
else if(l_lang == "en")
{
  // Code for english language
}

:

else
{
  // Fallback if language is missing (default language of the portal)
}

        

The oHtmlRoot object can also be used to determine the portal's default language.

            var l_defaultLang = oHtmlRoot.oUp.oFormatInfo.defaultLang;

Um im Velocity-Kontext sprachabhängige Weichen zu konstruieren, kann die Intrexx-Systemvariable $lang verwendet werden, die die aktuell eingestellte Portalsprache enthält.

#if($lang == "de")
  // Language dependent code
#elseif($lang == "en")
  // Language dependent code
#else
  // Fallback in case of missing language
#end

        

There are several ways to generate multilingual data in Groovy scripts or to control certain actions based on the language.

            // Current portal language
g_language
// Default language of the portal
g_defaultLanguage
// Current portal language via request parameter rq_Lang 
g_request.get("rq_Lang")
// Default language Users from the current session
g_session.user.getDefaultLanguage()

        

A switch-case statement can be used to create a language switch for various purposes.

            switch(g_language)
{
  case "de":
    return german
    break
  case "en":
    return english
    break
  default:
    return english
}

        

Multilingual Graphics

If graphics are managed by data groups, these can be defined for each language-specific dataset. Displaying language-dependent graphics in the layout is more difficult, as this is not technically supported. Here is the approach: add the ISO language code to the file name of the image and use a Velocity script to construct the URL based on the language set in the portal. The following ActionControl creates a DIV container with a link to the portal's home page and embeds an image based on the language. It is important to name the image logo_<ISO language code>.png. The control dynamically constructs the file name using the configured portal language $lang.

            <div id="Container_Logo">
	<a title="Home" href="/$Portal.getPortalName()">
		<img width="199" height="49" src="images/${layout}/logo_${lang}.png" alt="Home">
	</a>
</div>

        

Velocity Variables in Language Constants

In all language constants of the type "Language constant is evaluated as a Velocity expression," Velocity variables can be embedded when used on application pages. For this to work correctly, the variable must be available in the page context. In the following example, the variable $Rooms is embedded in the text so that the plain text is supplemented with a dynamic value—in this case, the number of rooms.

Constant text:

            There are $Rooms Room/Rooms in this building!
        

Issue: There are 10 rooms in this building!

Language Selector with Flags

A language selector with flags only makes sense for a few portal languages, and even then only in combination with the language name. For languages like English, which are spoken in multiple countries and are therefore associated with multiple flags, a flag-based language selector isn't always ideal either. Intrexx already provides a set of graphics featuring flags labeled with their ISO language codes. First, create a new file named "languageswitch_flag.vm" in the portal directory internal\system\vm\html\actioncontrol, and copy the following Velocity code into that file.

            #set($l_aAllLang = $WebMenu.getMenuLanguages())
<span id="ID_Languageswitch">#foreach($l_strLang in $l_aAllLang)
	#set($l_strImagePath = "images/assets/flags_of_the_world/16x16/plain/${l_strLang}.png")
	#set($l_strDisplayLang = $TextUtil.getDisplayLanguage($l_strLang, $l_strLang))
 	<a style="width: 16px; height: 16px; display: inline-block; background-repeat: no-repeat; background-position: center; background-image: url($l_strImagePath); cursor: pointer;" onclick="var oLangAction=setLangAction('$velocityCount', '$!l_strLang');oLangAction.changeLang();return false;" lang="$!l_strLang" target="_top" href="$Request.get('DEFAULT_URL')?rq_Lang=$!l_strLang" id="ID_actionLangSwitch${velocityCount}" title="$I18N.get('LANGUAGESWITCH_DESCRIPTION')"></a>#end
</span>
<script type="text/javascript">
	function setLangAction(count, lang){oLangAction = new upTextActionControl();oLangAction = oLangAction.biDirectUpHtml(oLangAction, 'ID_actionLangSwitch' + count);oLangAction.linkType = '4';oLangAction.oTarget = new upTarget();oLangAction.oTarget.rq_Lang = lang;return oLangAction;}
</script>

        

In the "controls.xml" file, insert the following block into the XML structure:

            <control id="Action_LanguageSwitchFlag" mobile="false" multipleUse="false" vm="languageswitch_flag.vm">
	<title lang="en" value="Language Switch with Flags"/>
	<title lang="de" value="Sprachumschalter mit Flaggen"/>
	<description lang="en" value="Language Switch"/>  
	<description lang="de" value="Sprachumschalter"/>
</control>

        

After restarting the Portal Manager, the additional control can now be selected and added to the layout.