Sign in to follow this  
Followers 0
AvvA

Independant language file (not compiled into the .exe)

2 posts in this topic

#1 ·  Posted (edited)

Hello there :D

First, thanks a lot for this great software ^^

Second, to describe what I need, it's an independant language file for my future script's users to traduct it in their own -unknown for me- language, and without the need of recompiling the script or contact me, I love freedom (for them of course ! What are you thinking ;) ?).

For this kind of purpose, I must write a human-readable language file.

Here is what I tried to do first, which works, but embbed the file when compiling :

- I make a file filled with $variable = "content", one per line.

- I #include it at the begining of my AutoIt script, and all was rolling like a charm :D

Until I compiled the thing, and try again to substitute the language file :S

So, I remembered that one of AutoIt purpose was to make standalone executables... better late than never :D

I spent the morning searching the forum for what i'll explain there, but nobody makes a multi-lingual GUI with non-embended text ? Well...

That's not a problem since this let me discover a bunch of usefull tips, by reading out of "my" topic things ;)

I found the nearly solution in this post.

I would like to thanks YellowLab and Xenobiologist for their close answer to my problem, that put me on the way.

My problem was that I came from the php/js/sql world, and try to... kind of reproduce what I usually do, I was wrong, of course !

After trying the 2 veterans's solutions (after modifying the Xenobiologist one, as i didn't need to rewrite a file ^^), I was a bit disapointed, it works, i converted my file to an INI file (removing all $ and ", making a section...)

And I realised that in the operation, all the " & @CR & " stays litterals :S

I try to play with the Opt("ExpandVarStrings", 1), but nothing to do, it stays like text.

So I try to play with execute() and string(), but still nothing.

The problem came from the the IniReadSection(), I don't know why, but it doesn't interpret the string like I want.

So I try to make my own dirty code, here it is : (yes, it works)

$langfile = FileOpen(@ScriptDir & "\language.lng",0)
If $langfile = -1 Then
    MsgBox(0, "Error", "Please, copy a language.lng file at the same level as AIscript.exe :" & @CR & @ScriptDir & "\")
    Exit
EndIf
While 1
    $langline = FileReadLine($langfile) ; Read the file, line by line
    If @error = -1 Then ExitLoop ; means EOF, stop reading and exit the loop ^^

    $varr = StringSplit($langline, " = ", 1) ; split only if space=space is found (option 1)
    if $varr[0]=2 then Assign($varr[1],execute($varr[2])) ; test if the line grabbed is valid, as some lines are empty, others are comments.

Wend
FileClose($langfile)ƒoÝŠ÷ Ù&¦¦W¥jx.jŸŠW­¢ÈhÃ*.¶«Šm³)íkhºÇšºÚ"µÍŽØÙYšXØ]B›[™×ÝX—ØÙYšXØ]H  œ][ÝÐÙYšXØ]Iœ][Ý›[™×ØÙÚ[™›ÈH œ][ÝÕÙH[™›Ü›X][ÛœÈÚ[™HÚÝÛˆÈ[݈ҔÈÚ]HšÚ]ÜœËZ]ˆÚ[ˆXØÙ[™ÈHÙYšXØ]H܈žHXZÚ[™È[ˆ^Ù[ÛˆYˆÙYšXØ]HÛ‰ˆÌÎNÝ™XÛÙÛš^™HȘ[Y‰œ][ÝÈ    ˜[ÈÔˆ   ˜[È   œ][ÝÕH™YšY[[ˆÈXˆÚÝ[ÛÛZ[œÈ[݈T”Ü܈H˜[YHÙˆ[݈Ú]HYˆ[ÝHÜÈHH[™œÈÙšXÙKHÙXˆ›ÜØ™[™ÈÙšXÙK܈]™H™YÚÝ™Y[݈T[™ˆHÛXZ[ˆ˜[YHˆÝÝË›^Ú]K˜ÛÛH‰œ][ÝÈ   ˜[ÈÔˆ   ˜[È   œ][ÝÕÈšY[ÚÝ[ÛÛZ[ˆHY™ÜÈÈ™XXÚ[݈ҔÈÚ]KÚ]Ý]›ÝØÛÛ
‹ËÈ܈΋ËÊK‰œ][Ý‚ŽÈÛÛ[[Û‚›[™×ÛÚÈH  œ][ÝÛÚÉœ][Ý›[™×Ùœ›ÜˆH   œ][ÝÑœ›Ü‰œ][Ý›[™×ÝØ›š[™ÈH œ][ÝÕØ›š[™È   ˆÌÌÎÉœ][Ý›[™×Ùš[WÛݙܚ]HH œ][ÝÕÛÝ[[ÝHZÙHÈݙܚ]HÈš[HÉœ][Ý

This is : name_of_the_future_variable = "value of the variable"

As you can see, you can put blank lines, comments, as long as you don't use the separator in it. (and even if you do, you'll just create a useless variable.

I strongly recommand that you start all variable with a common exclusive prefix, to avoid overwriting an existing variable.

The big point in this is that languages are really differents, in french my file is 9Ko for 8Ko in english (for only 100 variable's line), this also means that @CR won't fit at the same place between two languages, most of the time. I couldn't take the Xenobiologist solution and force the break by making 3 variables, one per line...

Et voilà, the solution that leave your users free to translate yours scripts, without the assle of waiting for them to finish for you to recompile :P

I hope that can help some people out there ^^

So, by curiosity, there is no way to #include a file without embbeding it when compiling ? No similar thing ? I still like the first way i do, because it's operation free, just variable declaration, "too bad" it is automaticaly embbed ^^.

Edited by AvvA

Share this post


Link to post
Share on other sites



Just for information, I just quick edit the post, and the autoit-quote of the sample language file become that strange nasty bunch of unreadable characters ^^

I can't delete this topic, but the first admin/modo who pass here can do it, sorry for the double post, i just didn't want to rewrite it all and back until i get my "before-posting" editing box, and then repost :D

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