Jump to content

How to work fast with multiple languages?


Recommended Posts

Hi guys,

i want to make my program multilanguage etc. Well, some programs have .lng files, where the translation is put in, just like this one:

http://www.feedreader.com/translations/Dutch/translation.lng

How can i work quick with .lng-files?

Or is it maybe more handy to use .ini-files (in my case)?

greetings,

Andreas

Edited by Noobster24
Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.
Link to comment
Share on other sites

Yes, you could make each one an ini file and have them with a .lng extension. It wouldn't matter since autoit doesn't care about the file extension of an ini file. You could arrange the ini file into sections. For example, one section could be menus, one could be buttons, and one could be labels. Each label, button, and menu control would get its own key. You would then read the ini file with the .lng file extension and then set the text values of those controls to whatever it read they were in the ini file(that happened to have a .lng extension).

This is just one way you could do it, there are many other ways. I see this one as a pretty straight forward way to do it though.

EDIT

After examining the .lng file you posted a link to, i would like to inform you that the .lng file is nothing but an ini file with a .lng file extension, just as i suggested to do above.

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

Yes, you could make each one an ini file and have them with a .lng extension. It wouldn't matter since autoit doesn't care about the file extension of an ini file. You could arrange the ini file into sections. For example, one section could be menus, one could be buttons, and one could be labels. Each label, button, and menu control would get its own key. You would then read the ini file with the .lng file extension and then set the text values of those controls to whatever it read they were in the ini file(that happened to have a .lng extension).

This is just one way you could do it, there are many other ways. I see this one as a pretty straight forward way to do it though.

EDIT

After examining the .lng file you posted a link to, i would like to inform you that the .lng file is nothing but an ini file with a .lng file extension, just as i suggested to do above.

Yeah ok, thanks, i think i can figure it out now ;)

Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.
Link to comment
Share on other sites

Yeah sounds good, thanks for that. I would say something like this:

Global $lngfile = @ScriptDir & '\Files\Languages\' & $suffix & '.ini'
$varlang = IniReadSection($lngfile, "Program")
If @error Then MsgBox(0, "", "Error occurred, probably no INI file. Reinstall Online Serial Searcher to solve the problem.")
For $i = 1 To $varlang[0][0]
    $trans[$i] = $varlang[$i][1]
Next

But this gives an error:

C:\Documents and Settings\Andreas Vliegen\Desktop\Programmeren\AutoIt\~ OSS ~\OSS AU3\oss.au3 (55) : ==> Variable used without being declared.: 
$trans[$i] = $varlang[$i][1] 
^ ERROR
>Exit code: 0   Time: 0.417

That means that the variable $trans has not been used anywhere previously in the script and autoit has no idea what its value is. So declare it and fill its array with values and it won't give you an error anymore.

EDIT

Do this

Global $lngfile = @ScriptDir & '\Files\Languages\' & $suffix & '.ini'
$varlang = IniReadSection($lngfile, "Program")
If @error Then MsgBox(0, "", "Error occurred, probably no INI file. Reinstall Online Serial Searcher to solve the problem.")
Dim $trans[$varlang[0][0]]
For $i = 1 To $varlang[0][0]
    $trans[$i-1] = $varlang[$i][1]
Next
Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

That means that the variable $trans has not been used anywhere previously in the script and autoit has no idea what its value is. So declare it and fill its array with values and it won't give you an error anymore.

EDIT

Do this

Global $lngfile = @ScriptDir & '\Files\Languages\' & $suffix & '.ini'
$varlang = IniReadSection($lngfile, "Program")
If @error Then MsgBox(0, "", "Error occurred, probably no INI file. Reinstall Online Serial Searcher to solve the problem.")
Dim $trans[$varlang[0][0]]
For $i = 1 To $varlang[0][0]
    $trans[$i-1] = $varlang[$i][1]
Next
Yeah thanks, 2 min after i posted that, i solved it, but thanks anyway! :lmao:;)
Programs so far:Teh Serializer - Search for licenses for Nero - Windows - Office - Alcohol etc.
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...