James Posted January 15, 2007 Share Posted January 15, 2007 (edited) I was thinking about this earlier so I tried it. I was thinking of making language packs. This is how it would work. There would be an .ini file named "languages.ini" and it would be set up like: [English]GuiName=EnglishGui File1Name=EnglishFile1 etc etc [French] GuiName=FrancaisGui File1Name=Francais etc etc Then you would make a function which would read the Keys and set $GUI to what ever the value is. It's hard to explain, but I have tried my best. The GUI of the program would be: #include <GUIConstants.au3> $GUI = GUICreate(LanguagePacks("English", ($GuiLang), "1"))), 378, 304, 193, 115) $MenuItem3 = GUICtrlCreateMenu("") $MenuItem2 = GUICtrlCreateMenu("") $MenuItem1 = GUICtrlCreateMenu("") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd If you don't understand then I can try and explain again. Secure Edit: I forgot the question and why it would be used The question is, how would I make it read everything? And th reason, is so that programs can be used all the time, in all languages. Edited January 15, 2007 by Secure_ICT Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Helge Posted January 15, 2007 Share Posted January 15, 2007 It might be my eyes but I'm failing to see a question in your post... is there any ? Link to comment Share on other sites More sharing options...
James Posted January 15, 2007 Author Share Posted January 15, 2007 Yes. Basically, how would I make the program read the ini? [English]GuiName=EnglishGui File1Name=EnglishFile1 etc etc [French] GuiName=FrancaisGui File1Name=Francais etc etc I want a function to read the .ini which would then set the program up. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
BALA Posted January 15, 2007 Share Posted January 15, 2007 What would this do, translate a sentence to another language? [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com Link to comment Share on other sites More sharing options...
James Posted January 15, 2007 Author Share Posted January 15, 2007 Yes, it would also allow menus and labels etc, to be translated almost at startup. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
BALA Posted January 15, 2007 Share Posted January 15, 2007 How about IniRead "Reads a value from a standard format .ini file. " [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com Link to comment Share on other sites More sharing options...
James Posted January 15, 2007 Author Share Posted January 15, 2007 I was trying to use that, but I don't know how to read the value. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Danny35d Posted January 15, 2007 Share Posted January 15, 2007 To do what you want you need to use IniReadSection ( "filename", "section" ) which returns a 2 dimensional array where element[n][0] is the key and element[n][1] is the value. AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
James Posted January 15, 2007 Author Share Posted January 15, 2007 OK. That sounds good to me, I will try it now. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Helge Posted January 15, 2007 Share Posted January 15, 2007 (edited) How about having three arrays... Number one contains the default text for the controls, the second contains the key-names for the INI-sections and the third contains the corresponding controlIds. Start by setting the default text for the controls, by For/Next-looping the first and the third array. When you want to change the language you just loop through the second array and checks every INI-keys there. By setting INIRead's 4th parameter to "" you'll catch both if the key is missing and if it has no specified value. So, if there's a blank key-value you skip it and leave the control's text as it is, but if ain't you update the control, using the controlId contained in the third array. Might become messy if you're thinking of frequently updating the arrays, making it hard to ensure that they're actually corresponding but this was the first thing that came to my mind. It's effective, short but as I said it could become messy if lengthy. Example for updating text at language-change :For $i = 0 To Ubound($keynames) - 1 $text = IniRead("language.ini", $langname, $keynames[$i], "") If $text <> "" Then GUICtrlSetData($controls[$i], $text) Next Edited January 15, 2007 by Helge Link to comment Share on other sites More sharing options...
James Posted January 15, 2007 Author Share Posted January 15, 2007 Wow, ok, thats complicated. Would you show me where that would go? This is more difficult than I though it would be :S Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Helge Posted January 15, 2007 Share Posted January 15, 2007 Wow, ok, thats complicated. Would you show me where that would go? This is more difficult than I though it would be :SIt's not really that complicated, it's just that I'm not too good in wording my thoughts. I could make it easier forme by explaining it in Norwegian but that wouldn't help you too much. I could show a simple example, but thatwould have to wait about an hour as I'm on my way out... We'll see. Link to comment Share on other sites More sharing options...
James Posted January 15, 2007 Author Share Posted January 15, 2007 Hmm.. Norweigan, I don't think thats any good to me An example would do great. I can wait an hour or so, it's just an idea that would be really nifty for BetaPad and other projects. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
Danny35d Posted January 15, 2007 Share Posted January 15, 2007 Wow, ok, thats complicated. Would you show me where that would go? This is more difficult than I though it would be :SI know there are better way. This is an example, it may give you an idea... LanguageTest.au3 I couldn't attach the Language.ini file. [English] String_1 = Language Test String_2 = Ready String_3 = &File String_4 = Open String_5 = Help String_6 = Save String_7 = Info String_8 = Exit String_9 = Recent Files String_10 = View String_11 = Statusbar Stirng_12 = This is just a test of how to switch language..... String_13 = Select Language String_14 = OK String_15 = Cancel String_16 = Choose file... String_17 = Only a test... [spanish] String_1 = Prueba De Lenguaje String_2 = Listo String_3 = &Archivo String_4 = Abrir String_5 = Ayuda String_6 = Guardar String_7 = Info String_8 = Salida String_9 = Reciente Archivos String_10 = Mirrar String_11 = Barra de information Stirng_12 = Esto es una prueba como cambiar idomas String_13 = Seleccione Idiom String_14 = OK String_15 = Cancelar String_16 = Selccione Archivo... String_17 = Solamente una prueba... AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
Helge Posted January 15, 2007 Share Posted January 15, 2007 (edited) Here it goes... I made a Norwegian translation of the File-menu for notepad, and I also includedthe English as well, just for the heck of it.I made it as simple as possible so there's no selecting of languages GUI-wise for example...It shouldn't be too hard to add though... Personally I would prefix all language- sections with "L:",use IniReadSectionNames to get all sections and then filter out those not starting with the prefix.I would then add them to a menu, use GUICtrlSetOnEvent on the items and then in the event-function pass LangSet the value of GUICtrlRead(@GUI_CTRLID, 1).I never use onEvent-mode, but I believe it will work...also I think remember seeing you use itso there's no need to rewrite anything on your side. Hopefully it's less complicated now after yousee it in action.EDIT : changed to onEvent-mode and added my suggestions mentioned above. Edited January 15, 2007 by Helge Link to comment Share on other sites More sharing options...
James Posted January 15, 2007 Author Share Posted January 15, 2007 Thats great! Now if I wanted to add more languages, I could just add it to the bottom of Languages.ini right? Secure Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
James Posted January 15, 2007 Author Share Posted January 15, 2007 Personally, I find Helge's easier. But both are the same idea. I added L33T to the languages.txt Is it alright, if I was to use it in BetaPad? Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
BALA Posted January 15, 2007 Share Posted January 15, 2007 Though wouldn't this method be limited as you would have to input every word in the entire language, or at least a great deal of them? [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com Link to comment Share on other sites More sharing options...
James Posted January 15, 2007 Author Share Posted January 15, 2007 That's why I have many bi-lingual friends. They said they would do translations Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
BALA Posted January 15, 2007 Share Posted January 15, 2007 That's why I have many bi-lingual friends. They said they would do translations Yeah that too, but I meant on size of the file [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now