Jump to content

multilingual script


Recommended Posts

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

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...