Sign in to follow this  
Followers 0
MaartenDuits

multilingual script

4 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


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
Sign in to follow this  
Followers 0