TheDcoder Posted July 11, 2020 Share Posted July 11, 2020 Hello everyone! It has been a very long time since I made a post in this forum 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 - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
mikell Posted July 13, 2020 Share Posted July 13, 2020 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 comment Share on other sites More sharing options...
TheDcoder Posted July 13, 2020 Author Share Posted July 13, 2020 (edited) Maybe, I did not give it much thought 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 July 13, 2020 by TheDcoder EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
jchd Posted July 13, 2020 Share Posted July 13, 2020 Don't make your coding difficult! expandcollapse popup; 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 TheDcoder 1 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 hereRegExp tutorial: enough to get startedPCRE 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 comment Share on other sites More sharing options...
water Posted July 13, 2020 Share Posted July 13, 2020 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. TheDcoder 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
jchd Posted July 13, 2020 Share Posted July 13, 2020 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 hereRegExp tutorial: enough to get startedPCRE 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 comment Share on other sites More sharing options...
water Posted July 13, 2020 Share Posted July 13, 2020 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 2024-07-28 - Version 1.6.3.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 (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
argumentum Posted July 14, 2020 Share Posted July 14, 2020 ...why not an external file ( .ini or .lng ) where the user can provide a translation, saving you from guessing a language you are not very familiar with. ( my 2 cents ) TheDcoder and Danp2 2 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
TheDcoder Posted July 14, 2020 Author Share Posted July 14, 2020 @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 - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
jchd Posted July 14, 2020 Share Posted July 14, 2020 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 && hpp: *.cpp *.cxx *.h *.hxx *.hpp Find in all files except exe, obj && 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 hereRegExp tutorial: enough to get startedPCRE 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 comment Share on other sites More sharing options...
TheDcoder Posted July 14, 2020 Author Share Posted July 14, 2020 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 - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
mikell Posted July 15, 2020 Share Posted July 15, 2020 On 7/14/2020 at 2:24 AM, argumentum said: ..why not an external file It's obviously the most handy and versatile way. Most multilingual softwares have English language hardcoded and provide external language files. This way allows easy corrections, further language additions etc argumentum and Musashi 2 Link to comment Share on other sites More sharing options...
Nine Posted July 15, 2020 Share Posted July 15, 2020 (edited) 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 July 15, 2020 by Nine Musashi 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
TheDcoder Posted July 16, 2020 Author Share Posted July 16, 2020 @Nine Sounds interesting, by "database" I assume you mean an SQLite database? EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Nine Posted July 16, 2020 Share Posted July 16, 2020 @TheDcoder Not necessarily SQLite. Any DB would fit. Oracle was my first love, but of course SQLite is now a good choice as it is free, uses low resources and performs very well. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Earthshine Posted July 16, 2020 Share Posted July 16, 2020 (edited) 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 July 16, 2020 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
MrCreatoR Posted July 16, 2020 Share Posted July 16, 2020 Check out my ATT - Application Translate Tool. TheDcoder 1 Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: 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 ProgramUDFs: 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 Examples: 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 ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
TheDcoder Posted July 16, 2020 Author Share Posted July 16, 2020 @Nine I see, a fully-fledged DB seems to be an over-kill, but it is an option nonetheless @MrCreatoR Nice, I came across it once but I wasn't able to find it after that. EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
TheDcoder Posted August 31, 2020 Author Share Posted August 31, 2020 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! argumentum 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
TheDcoder Posted September 30, 2020 Author Share Posted September 30, 2020 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. argumentum 1 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now