Groumphy Posted March 29, 2005 Share Posted March 29, 2005 According to you, which is the most effective manner to have an interface in several languages ? 1 - To open a file in which are contained the various sentences in various languages ? $langue_langue = FileOpen("langue.langue", 2) Dim $langue_ligne1, $langue_ligne2 $langue_ligne1 = FileReadLine($langue_langue, 1) $langue_ligne2 = FileReadLine($langue_langue, 2) MsgBox(0 + 16, "Nadia - " & $langue_ligne1, $langue_ligne2) 2 - To create different scripts reacting correctly at the requests of language? -----> Gui for select a language ------> Start de GUI with the required language 3 - Another manner ? Thank you for your opinions and your examples Groumphy ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
Insolence Posted March 29, 2005 Share Posted March 29, 2005 Something like the first one. Dim $arCaption $Language = "English" _FileReadToArray($arCaption, $Language & ".txt") Not sure about the FileReadToArray syntax, but something like that. "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
Groumphy Posted March 31, 2005 Author Share Posted March 31, 2005 Thanks for your help and your answer. But how to make then to determine the place of the lines ? 1- FileReadLine in variables ? 2- Use the Under Array Number ? Can you give a sample with a MsgBox ? Thanks, Groumphy ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
Helge Posted March 31, 2005 Share Posted March 31, 2005 Hi Groumphy !In a script Im coding Ive added support for the user to select between several languages to be used in a GUI.As well as easily add new languages. The way this is done is by using a INI-file which looks something like this :[settings] language=Norwegian [L:Norwegian] hello=hallo name=navn age=alderSo when the script starts up, it sets some variables with the default text as value (English in my script).It then INIReads the LANGUAGE-key in the SETTINGS-section, and the use this key to see if thereis a valid INI-section with that value (starting with "L:" just to make it more systematic), and checksif all the required keys are filled in. If it is a valid languge-section it overwrites the variables with the new values.Understand ? Link to comment Share on other sites More sharing options...
Groumphy Posted April 2, 2005 Author Share Posted April 2, 2005 Thank you for your assistance, but unfortunately I does not understand. How can I make go automatically script to the good language ? How can I incorporate the variables in script? Can you give a simple (most easyly for you) ? For the moment, I use the opening of a file which I read, line by line... ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
Lazycat Posted April 3, 2005 Share Posted April 3, 2005 In one my script I have used very simple translation method (it's fairly similar Helge's method): Dim $inifile = "language.ini" MsgBox (0, "Translated", LocStr("My Program")) Func LocStr($str) Local $ret = IniRead($inifile, @OSLang, StringStripWS($str, 3), $str) If $ret = "" Then Return $str Return $ret EndFunc where language.ini is (for example): [040C] My Program=Mon programme [0419] My Program=Моя программа If string is not found then default string will be returned. One possible disadvantage of this method - frequently access to ini file every time when string need to be translated. Language codes you can find in the Appendix of Autoit help file. Koda homepage ([s]Outdated Koda homepage[/s]) (Bug Tracker)My Autoit script page ([s]Outdated mirror[/s]) Link to comment Share on other sites More sharing options...
Groumphy Posted April 5, 2005 Author Share Posted April 5, 2005 Thank you, I understood the example perfectly. This is perfect 've a nice day ----------------------GroumphyMore information about me [Fr] Link to comment Share on other sites More sharing options...
Kerberuz Posted April 5, 2005 Share Posted April 5, 2005 3 - Another manner ?I prefer using an array to read from the file. It's much quicker than reading and evaluating line by line. Here is an example I wrote in about 5 min.expandcollapse popup; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.1.0 ; Author: Kerberuz ; ; Script Function: ; Lang Switcher ; ; ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <File.au3> #include <GUIConstants.au3> Dim $aLang $Lang = Iniread ("InitLang.ini", "Language", "Lang", "") If $Lang = "" Then $Lang = 'NAE' EndIf _FileReadToArray ("Lang." & $Lang, $aLang) $GuiName = GUICreate(StringReplace($aLang[1], @CR, ""), 200, 200) $Label1 = GUICtrlCreateLabel($aLang[2], 10, 20) $Label2 = GUICtrlCreateLabel($aLang[3], 10, 50) $Label3 = GUICtrlCreateLabel($aLang[4], 10, 80) $Label4 = GUICtrlCreateLabel($aLang[5], 10, 110) $Label5 = GUICtrlCreateLabel($aLang[6], 10, 140) $Switch = GUICtrlCreateButton("Language is " & $Lang, 10, 170) GUISetState (@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop If $msg = $Switch Then if $Lang = 'NAE' Then IniWrite ("InitLang.ini", "Language", "Lang", "EUG") _FileReadToArray ("Lang.EUG", $aLang) SwitchLang() Else IniWrite ("InitLang.ini", "Language", "Lang", "NAE") _FileReadToArray ("Lang.NAE", $aLang) SwitchLang() EndIf EndIf Wend Func SwitchLang() $Lang = Iniread ("InitLang.ini", "Language", "Lang", "") WinSetTitle ( $GuiName, "", StringReplace($aLang[1], @CR, "") ) GUICtrlSetData( $Label1, $aLang[2]) GUICtrlSetData( $Label2, $aLang[3]) GUICtrlSetData( $Label3, $aLang[4]) GUICtrlSetData( $Label4, $aLang[5]) GUICtrlSetData( $Label5, $aLang[6]) GUICtrlSetData( $Switch, "Language is " & $Lang ) EndFuncHere are examples of the lang files I built, but they could be much more elaborate.Save this as Lang.EUGGerman Language German Elements German Dog German Fish German Smurf German WaterSave this as Lang.NAEEnglish Language English Elements English Dog English Fish English Smurf English Water Kerby Link to comment Share on other sites More sharing options...
Groumphy Posted April 7, 2005 Author Share Posted April 7, 2005 Ok, I understood too ! Your script is preferential on large scripts, but here, the preceding method (LazyCat) is adapted better to script than I builds (simple script to build and generate a file via a GUI and to print this last on the default printer of the computer). I keep your method for scripts more complete ! Thanks for you help ! be Groumphy ----------------------GroumphyMore information about me [Fr] 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