Can you build Multi-Lingual mobile and web apps with Alpha Anywhere ? Si, Ja, Yes, Jawohl

Blog



Can you build Multi-Lingual mobile and web apps with Alpha Anywhere ? Si, Ja, Yes, Jawohl

Multi-language support can indeed be handled in Alpha Anywhere.

A quick primer.

There are two ways to handle this - server-side or client-side.

The existing documentation for this feature assumes that you are doing this server-side. The strings in the application are wrapped in "language tags" or "text dictionary" tags and then when the component is served by the Alpha Application Server, the tags are replaced.

For example, you might have a label in a component called "Lastname" - you would change the label to <a5:r>Lastname</a5:r> (this is a Language tag) or to <a5:t>Lastname</a5:t> (this is a text dictionary tag).

If you go to the video finder (help/video finder) and search for 'language tags' you will see several videos on the subject.

videoLibraryLanuagetags.png

However, in a mobile application, especially a phonegap application, using server-side language tags or text dictionary tags might not be appropriate because the app is loaded from the phonegap package stored on the device -- it is NOT typically loaded by making a callback to the server.

Therefore you would need to implement a client-side solution to the problem. this can easily be done using some JavaScript. The approach is as follows:

1.  Wrap all of the strings in the app that you need to translate in <span> tags and give each span a unique id. For example

<span id="_language_LASTNAME">LastName</span>

2. Create a .js file that is linked into the UX component that has the translations for each string. For double byte characters your .js file will probably need to use the Javascript Unicode encoding format. The .js file will look something like this:

var _translation = {
    "LASTNAME" : {
        "english" : "Lastname",
        "french" : "LASTNAME in french",
        "spanish" : "LASTNAME in spanish"
    },
    "FIRSTNAME" : {
        // DEFINITION FOR FIRSTNAME IN ALL LANGUAGES
    }
}

At run-time, when the user want's to change from one language to another, your JavaScript would loop over all of the ids that need to be changed, and set the value to the correct string.

For example to get the value of the 'lastname' field in spanish, you could do the following:

$('_language_LASTNAME').innerHTML = _translation['LASTNAME']['spanish'];

You can handle Chinese or Japanese. all database access in alpha anywhere is UTF8, so any data that comes from a SQL database will just work.

With static data (such as a label that you enter into the UX component builder), you would need to use encoding.

If you go to the Tools menu, when the web control panel has focus, you will see a menu command "Open Text Encoder window" that you can use to encode the strings.

Note - to find out about langauges that operate Right to Left (for example Arabic and Hebrew)  vs Left to Right, check out this previous blog post.

One of the Keynote Speakers at the Alpha Developer Conference 2015 has a new book on User Experience
The Rise of Low-Code App Platforms

About Author

Richard Rabins
Richard Rabins

Co-founder of Alpha Software, Richard Rabins focuses on strategy, sales, and marketing. Richard also served as CEO of SoftQuad International from 1997 to 2001, when it owned Alpha. In addition to his 30 years with the company, Richard played a key role as co-founder, and served as president and chairman of the Massachusetts Software Council (now the Massachusetts Technology Leadership Council), the largest technology trade organization in Massachusetts. Prior to founding Alpha, Richard was a project leader and consultant with Information Resources, Inc. (IRI), and a management consultant with Management Decision Systems, Inc. Richard holds a master's degree in system dynamics from the Sloan School at MIT, and a bachelor's degree in electrical engineering and master's degree in control engineering from University of the Witwatersrand in Johannesburg, South Africa. He has served on the boards of Silent Systems, Legacy Technology and O3B Networks, and is co-founder of Tubifi www.tubifi.com.

Comment

Subscribe To Blog

Subscribe to Email Updates