Howto:Localized Canvas GUI dialogs

From FlightGear wiki
Jump to navigation Jump to search
This article is a stub. You can help the wiki by expanding it.
WIP.png Work in progress
This article or section will be worked on in the upcoming hours or days.
See history for the latest developments.

Motivation

Objective

Background

you can then simply use a hash map to emulate a multi-language dialog - in contrast, any Canvas element, including GUI widgets (labels) is a fully dynamic thing - thus, there is no workaround needed. All you need to do is to set up a hash with strings for each language you'd like to support, at that point you can simply set the value of the label by retrieving the correct string from the hash[1]


Example

    var STRINGS = {
    ENGLISH: {
    hello: 'hello',
    world: 'world',
    }, # end of english strings

    FRENCH: {
    hello: 'bonjour',
    world: 'monde',
    }, # end of french strings


    SPANISH: {
    hello: 'hola',
    world: 'mundo',
    }, # end of spanish strings

    };

    var language = 'SPANISH';

    print( STRINGS[language].hello );
  1. Hooray  (Aug 13th, 2016).  Re: User language .