Jump to content

Techniques for multi-lingual GUI design


Recommended Posts

Hello everyone! :bye:

It has been a very long time since I made a post in this forum :D

I am working on a freelance project which requires me to create a multi-lingual GUI, and I could think of a few ways to do that. But I want to know what you guys have in store for this, please share all of your awesome tips and hack for creating multi-lingual GUIs.

If this thread gets enough submissions, maybe we can make this into a meta-thread listing all of the techniques.

Thank you for the submissions in advance!

Regards,
TheDcoder.

EasyCodeIt - A cross-platform AutoIt implementation

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites
On 7/11/2020 at 11:03 AM, TheDcoder said:

I could think of a few ways to do that

Wow. So much ?
Given the requirements in such a situation (i.e. mainly allow further additions) , IMHO there are not 50 ways to do that... maybe you will get slight differences in the flavour but the concept will remain the same  :)

Link to post
Share on other sites

Maybe, I did not give it much thought :D

I am working on my own sloppy system right now, which looks like this:

Global Enum $L_DUMMY, _
$L_TITLE, _
$L_FOO, _
$L_BAR, _
$L_DUMMY2

Global Const $L_EN[5] = ["", _
    "Hello World", _
    "Foo", _
    "Bar", _
    "" _
]

Global Const $L_HI[5] = ["", _
    "नमस्कार दुनिआ", _
    "गु", _
    "गाली भरो मादर***", _
    "" _
]

Global $l = $L_HI

 

Edited by TheDcoder

EasyCodeIt - A cross-platform AutoIt implementation

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites

Don't make your coding difficult!

; supported languages
Global Enum $LANG_EN, $LANG_RU, $LANG_DE, $LANG_FR

; give strings a readable codename instead of an error-prone index
Global Enum $MSG_Close, $MSG_StdChkBox, $MSG_Quit, $MSG_ChkedBox, MSG_UnChkedBox

; array of string by language, string
Global $Dictionary = [ _
    [ _                         ; EN
        "Close", _
        "Standard Checkbox", _
        "Quit", _
        "The checkbox is checked.", _
        "The checkbox is not checked." _
    ], _
    [ _                         ; RU
        "близко", _
        "Стандартный флажок", _
        "Уволиться", _
        "Флажок отмечен.", _
        "Флажок не отмечен." _
    ], _
    [ _                         ; DE
        "Schließen", _
        "Standard-Kontrollkästchen", _
        "Verlassen", _
        "Das Kontrollkästchen ist aktiviert.", _
        "Das Kontrollkästchen ist nicht aktiviert." _
    ], _
    [ _                         ; FR
        "Fermer", _
        "Case à cocher standard", _
        "Quitter", _
        "La case est cochée.", _
        "La case n'est pas cochée." _
    ] _
]

; language in force
Global $Lang

;===========================================================================
; example use
;---------------------------------------------------------------------------
; randomly select a language and display some strings
For $i = 1 To 3
    $Lang = Random($LANG_EN, $LANG_FR, 1)
    Use_Example()
Next

Func Use_Example()
    For $i = 1 To 3
        MsgBox(0, "", $Dictionary[$Lang][Random(0, UBound($Dictionary, 2) - 1, 1)])
    Next
EndFunc

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites

Before coding I think you need to make some decisions:

  • Do you just want to support left-to-right languages or right-to-left languages as well?
  • How do you handle languages that need more space in a GUI than others (e.g. "food intolerance" needs more space in German: "Nahrungsmittelunverträglichkeit").
    Do you want to use smaller fonts, line breaks ... to not have this literals truncated?
  • How do you handle untranslated literals? What's the default language to use in this case?
  • ...

Many years ago (~ 2008) I have written an UDF to allow multi language error messages.
it reads language dependant literals from a file, replaces placeholders with variable data and returns the string to the script.
Unfortunately it doesn't handle any of the mentioned problems.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites
3 minutes ago, water said:

Do you just want to support left-to-right languages or right-to-left languages as well?

Not an issue at all, thanks to Unicode!

4 minutes ago, water said:

How do you handle languages that need more space in a GUI than others (e.g. "food intolerance" needs more space in German: "Nahrungsmittelunverträglichkeit").

Can be handled with the UDF @Melba created for this (StringSize or something).  It's also relatively easy to create a crude and simple string splitter, even if very far from LaTeX.

More difficult is to design GUI elements elegantly fitted to a variey of languages.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites
44 minutes ago, jchd said:

Do you just want to support left-to-right languages or right-to-left languages as well?

I was thinking of the RTL extended styles like $WS_EX_LAYOUTRTL, $TVS_RTLREADING etc. But I have never used them myself.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to post
Share on other sites

@jchd Thanks for your alternate method of using a 2D array instead of an 1D approach like myself. Some people might prefer a 1D approach as it makes the expression shorter ($l[$L_EN][$L_FOO] vs $l[$L_FOO])

@water You have raised some very good points, especially the point about GUI layout.

@argumentum Absolutely doable, that is what I originally wanted to do, but decided against that to make things simpler (in the short term). There is an excellent UDF called AU3Text by @dany which does exactly this, and much more. It also contains a version of Ini functions which are capable of properly handling unicode input I think. Sadly the demo gave me a bunch of syntax error when I attempted to run it in the latest AutoIt :(

 

EasyCodeIt - A cross-platform AutoIt implementation

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites

An external source is open to misuse but maybe a good solution. For instance Notepad++ uses .xml files for its localization, implements in-band escapes to insert variables inside strings and even allows multiline text, e.g.:

<find-in-files-filter-tip value="Find in cpp, cxx, h, hxx &amp;&amp; hpp:
*.cpp *.cxx *.h *.hxx *.hpp

Find in all files except exe, obj &amp;&amp; log:
*.* !*.exe !*.obj !*.log"/>
...
            <find-status-replaceall-1-replaced value="Replace All: 1 occurrence was replaced"/>
            <find-status-replaceall-nb-replaced value="Replace All: $INT_REPLACE$ occurrences were replaced"/>
...
            <find-status-replaceinfiles-1-replaced value="Replace in Files: 1 occurrence was replaced"/>
            <find-status-replaceinfiles-nb-replaced value="Replace in Files: $INT_REPLACE$ occurrences were replaced"/>

Of course $INT_REPLACE$ would ideally take care of the script (= written language) used for a given translation, as latin and many others say 123456 when Devanagari would use १२३४५६

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites
2 hours ago, jchd said:

An external source is open to misuse

Indeed, no way to get around that. But really, if we are concerned about security there isn't much that can be done as the binary itself can be modified to change the strings.

Another advantage of external sources is that it makes it possible to just download the languages which are needed, as opposed to all supported languages, which would essentially be bloat.

EasyCodeIt - A cross-platform AutoIt implementation

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites

My personal preference is to go with a database.  It allows me to quickly get all labels, messages, errors, lists, etc.  What I usually do is to assign an ID to each pages of a GUI so I query in an array all the texts with a single call.

It is also extremely easy to add or remove a language.  I never hardcode a language, because if the client wants to modify a certain term, you do not need to provide a new set of exe, he can make his own modification without involving you.

Edited by Nine
Link to post
Share on other sites
Link to post
Share on other sites

20 or so years ago I  used an ini file With all the different languages for all the text boxes and controls and anything that had text on the form and message box text so when you load the form you have to iterate through all the controls on the form and look up what their text should be

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Link to post
Share on other sites

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to post
Share on other sites
  • 1 month later...
On 7/14/2020 at 2:27 PM, TheDcoder said:

There is an excellent UDF called AU3Text by @dany (...) Sadly the demo gave me a bunch of syntax error when I attempted to run it in the latest AutoIt :(

I have posted a fixed version in that thread, I am going to try it with a new project, wish me luck guys! :)

EasyCodeIt - A cross-platform AutoIt implementation

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites
  • 5 weeks later...

Due to several reasons, AU3Text was just not working out for me... so instead, I decided to create my own version:

It uses a forked version of EasyCodeIt to extract the translation strings and internally uses Scripting.Dictionary to keep track of the strings.

EasyCodeIt - A cross-platform AutoIt implementation

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...