MaartenDuits Posted December 1, 2009 Share Posted December 1, 2009 Hello all, I made a script with AutoIt and i would like it multilingual. I realy don't have an idea how to handle with it. Hope anybody can give me some tips. Thx in advance. Kind regards, Maarten. Kind regards,Maarten Link to comment Share on other sites More sharing options...
Mat Posted December 1, 2009 Share Posted December 1, 2009 use an ini file: [english] Button1=Ok Button2=Cancel [French] Button1=D'accord ... [German] ... Here is a very simple script that takes a script and replaces every string with a call to iniRead, with an index number for the string. It does affect some strings that you might not want it to, but unless you want to do this by hand its as good as it gets. $sFile = FileOpenDialog ("Open Autoit script....", @WorkingDir, "Autoit Scripts (*.au3)|All Files (*.*)") If @Error Then Exit 1 $sData = FileRead ($sFile) $aStrings = StringRegExp ($sData, "(["";'].*?["";'])", 3) $sIni = StringRegExpReplace ($sFile, "\\.*$", "") & "\lang.ini" FileWrite ($sIni, "[English]") For $i = 0 to UBound ($aStrings) - 1 $sData = StringReplace ($sData, $aStrings[$i], "IniRead ($LANG_Ini, $LANG_Cur, """ & $i & """, " & $aStrings[$i] & ")") IniWrite ($sIni, "English", $i, $aStrings[$i]) Next $sData = "Global $LANG_Ini = @ScriptDir & ""\lang.ini""" & @CRLF & "Global $LANG_Cur = ""English""" & @CRLF & $sData FileWrite ($sFile & "_Multi.au3", $sData) MsgBox (64, "Complete", "Multi lingual script completed successfully.") Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
MaartenDuits Posted December 1, 2009 Author Share Posted December 1, 2009 Hello Mat, Thx for the reply and your good example. I was wondering isn't there a way to make everything work in one script? Thanks again. Maarten Kind regards,Maarten Link to comment Share on other sites More sharing options...
Mat Posted December 1, 2009 Share Posted December 1, 2009 You can load all the strings into an array, but that would take a lotta memory. Or you could use the ini file method, but use FileInstall to put it in @TempDir and read it from there. Alternatively try resources: http://www.autoitscript.com/forum/index.php?showtopic=51103 you want _ResourceGetAsString. Mat AutoIt Project Listing 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