Jump to content

Recommended Posts

Posted

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

Posted

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

Posted

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

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...