Jump to content

Add Tab and make it Multilingual


Recommended Posts

Hey guys. I have made an android rooting program with AutoIT and you guys always helped me out! I really appreciate it! I'm now planning to make it multilingual. I was looking at downloads here are the Countries will the top downloads:

1. USA (English)

2. UK (English)

3. Germany (Germen)

4. Spain (Spanish)

5. Canada (English/French)

6. Netherlands (Dutch)

7. France (French)

8. Italy (Italian)

9. Australia (English)

10.India (Not sure since they speak multiple languages)

Luckily, 4 of 10 speak English. I am having translators translate my script. I am wondering how I can add a tab where users can change the language to their desired one and the program will then change to that new language. I hope I am making it clear lol

Edited by hasoon2000
Link to comment
Share on other sites

Hi,

Just think of what could be the best possibility to change the language of your application without restarting it.

You can store in a 2D array the id of the control associated to its text.

;e.g:

#include <Array.au3>

Global Enum $label1, $label2 ;fake ctrl ids

Global $aLng[3][4] = [ _ ;ctrl, text
        ["ctrlid", "EN", "FR", "DE"], _
        [$label1, "Hello", "Bonjour", "Hallo"], _
        [$label2, "Goodbye", "Au revoir", "Auf wiedersehen"] _
    ]

_ArrayDisplay($aLng)

Br, FireFox.

Link to comment
Share on other sites

I have A LOT to get translated

That's not the point. You are not the program.

This was just an idea. You will have to fill that array with the file contents.

e.g:

#include <Array.au3>

Global Enum $label1, $label2 ;fake ctrl ids

Global $aCtrl[2] = [$label1, $label2]

Global $aLng = StringSplit(FileRead("en.txt"), @CrLf, 1)

;associate $label1 with $aLng[1] etc
_ArrayDisplay($aLng)

;"en.txt" content:
;Hello
;Goodbye

Again I'm not telling you this is the best thing to do.

Link to comment
Share on other sites

You kind of lost me. I have A LOT to get translated. Here is a link of what people are translating for me.

http://forum.xda-developers.com/showpost.php?p=37647712&postcount=5

the best way is using 2D arrays

following firefox example you just need to change a variable number to alternate from Gui language (of course, all ctrl's need to be updated/reloaded)

array/table:

["ctrlid", "EN", "FR", "DE"], _
[$label1, "Hello", "Bonjour", "Hallo"], _
[$label2, "Goodbye", "Au revoir", "Auf wiedersehen"]

you just need to loop between $aLng[1][lng column] to $aLng[n][lang column] to update all gui ctrls, you can do this automatcly (when gui starts, by reading system default language or be waiting for user input)

here's my example (1 ctrl to update) hope it helps

#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 329, 39, 236, 184)
$Combo1 = GUICtrlCreateCombo("", 176, 8, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "English|French|Deutch", "English")
$Label1 = GUICtrlCreateLabel("Hello", 8, 8, 162, 26, $SS_CENTER)
GUICtrlSetFont(-1, 14, 800, 0, "Arial")
Global $aLng[2][4] = [ _ ;ctrl, text
        ["ctrlid", "EN", "FR", "DE"], _
        [$Label1, "Hello", "Bonjour", "Hallo"] _
    ]
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Combo1
$rd = GUICtrlRead($Combo1)
Switch $rd
Case "English"
For $x = 1 To UBound($aLng)-1
GUICtrlSetData($aLng[$x][0],$aLng[$x][1])
Next
Case "French"
For $x = 1 To UBound($aLng)-1
GUICtrlSetData($aLng[$x][0],$aLng[$x][2])
Next
Case "Deutch"
For $x = 1 To UBound($aLng)-1
GUICtrlSetData($aLng[$x][0],$aLng[$x][3])
Next
EndSwitch
EndSwitch
WEnd

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Link to comment
Share on other sites

Al right. Here is some more info because I am still a little lost

$List1 = GUICtrlCreateList("", 40, 80, 121, 110)
GUICtrlSetData(-1, "1. Install HTC Drivers|2. Register at HTCDev|3. Get Token ID|4. Submit Token ID|5. Unlock Bootloader")
$Label1 = GUICtrlCreateLabel("To root the phone. Follow in order", 24, 48, 163, 17)
$List2 = GUICtrlCreateList("", 552, 80, 113, 97)
GUICtrlSetData(-1, "TWRP (S3)|TWRP (S4)|TWRP (Special Edition)|Your Own Recovery")
$Label2 = GUICtrlCreateLabel("Next, flash a recovery.", 552, 48, 110, 17)

Case $Go
         $selected = GUICtrlRead($List1)
         Switch $selected
Case "1. Install HTC Drivers"
MsgBox(0, "Installing HTC Drivers...", "This will install the HTC Drivers so ADB/Fastboot can detect your phone. This is NOT compatible with Windows 8!")
                 $start = Run($Driver, @ScriptDir & "\data\", @SW_Hide)
Case "2. Register at HTCDev"
MsgBox(0, "Opening HTCDev's Registration Website...", "This will open HTCDev's Registration Website. MAKE SURE TO USE A VALID EMAIL ADDRESS!! After you make an account, log in and leave the web browser open.")
                 ShellExecute ("https://www.htcdev.com/register/")
Case "3. Get Token ID"
MsgBox(0, "Getting Your Token ID...", "This will help you get your TOKEN ID. Make sure USB Debugging is enabled. You will have TWO screens. When your phone is in bootloader, close the first command prompt screen. A second screen will initiate and get the Token ID. Highlight from. <<<< Identifier Token Start >>>> all the way to <<<<< Identifier Token End >>>>>. Then right click and you have just copied your Token ID!")
RunWait($BIBL, @ScriptDir & "\data\", @SW_SHOW)
$start = RunWait($TokenID, @ScriptDir & "\data\", @SW_SHOW)
Case "4. Submit Token ID"
MsgBox(0, "Opening HTCDev's Token ID Submission Website...", "This will open HTCDev's Submission Website. Scroll to the bottom and paste your Token ID in the box and press Submit. It will email you your Token ID. If it tells you to log in, that means you didn't listen to me in Step 2 :( . Log in and come back to the toolkit and rerun this command")
ShellExecute ("http://www.htcdev.com/bootloader/unlock-instructions/page-3")
Case "5. Unlock Bootloader"
MsgBox(0, "Almost There! Now, time to unlock your bootloader...", "Here we go! Locate your Unlock_Code.bin. Make sure you are booted into bootloader. It MUST say FASTBOOT USB. (Make sure your USB cable is connected). Read HTC's warning. This WILL Factory Reset/WIPE out your entire phone! Back up ALL your files. Your External SD Card and SIM Card are phone. Anything on the internal storage will be deleted!!!")
$message= "Choose your unlock_code.bin"
$file3 = FileOpenDialog($message, @WindowsDir & "\", "Unlock_Code(*.bin)",1+4)
If @error Then
MsgBox(4096, "", "No Bin file selected")
Else
RunWait($UnlockBL & " " & $file3, @ScriptDir & "\data\", @SW_SHOW)
MsgBox(0, "unlock_code.bin flashed", "flash unlock_code.bin Done!")
EndIf
EndSwitch

So that is the KODA code and then the script of what it does. Someone translated it in German for me

1. HTC-Treiber installieren|2. Bei HTCDev registrieren|3. Token-ID bekommen|4. Token-ID abschicken|5. Bootloader unlocken
Zum Rooten folgendes ausführen.

"HTC-Treiber werden installiert", "Die HTC-Treiber werden installiert, damit ADB/Fastboot dein Smartphone erkennen kann. Nicht kompatibel mit Windows 8!")
HTCDev-Registrierungs-Website wird geöffnet...", "Dies öffnet die HTCDev-Registrierungs-Website. BENUTZE EINE GÜLTIGE EMAIL-ADRESSE!! Nachdem du ein Benutzerkonto angelegt hast, logge dich ein und lass den Browser geöffnet.")
Deine Token ID erhalten...", "Dies hilft dir deine Token ID zu erhalten. Versichere dich das USB-Debugging aktiviert ist. Zwei Fenster werden sich öffnen. Wenn dein Smartphone im Bootloader ist, schließe das erste Eingabeaufforderung-Fenster. Ein zweites Fenster wird geöffnet und zeigt dir deine Token ID an. Markiere alles von <<<< Identifier Token Start >>>> bis <<<<< Identifier Token End >>>>> und mache einen Rechtsklick um deine Token ID zu kopieren.")
Öffne HTCDevs Website zum Einsenden der Token-ID...", "Dies öffnet die HTCDevs Website zum Einsenden der Token-ID. Scrolle zum Ende der Seite und füge deine Token-ID in das Eingabefeld ein und drücke auf Submit. Du solltest nun eine E-Mail erhalten. Falls du die Meldung bekommst, dass du dich einloggen sollst, hast du Schritt 2 falsch ausgeführt. Logge dich ein und führ diesen Schritt nochmal durch.")
Fast geschafft! Jetzt können wir den Bootloader unlocken...", "Weiter geht's! Jetzt brauchen wir die Unlock_Code.bin. Vergewissere dich, dass dein Smartphone sich im Bootloader befindet. Es MUSS FASTBOOT USB im Display stehen! (Vergewissere dich, dass dein USB-Kabel angeschlossen ist) Lies den Warnhinweis von HTC. Hierdurch wird dein Smartphone auf Werkszustand zurückgesetzt, dass heißt ALLE deine Daten werden GELÖSCHT! Sichere ALLE deine Daten! Deine Daten auf der externen SD-Karte und SIM-Karte sind sicher. Alles auf deinem internen Speicher wird gelöscht!!!")
Wähle deine Unlock_Code.bin aus
Keine .bin-Datei ausgewählt
Unlock_Code.bin geflasht", "Unlock_Code.bin wurde geflasht!

I have MSGboxes and commands. I hope you guys are understanding that when I want the language switched, the whole program switches to that specific languages.

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