PDA

View Full Version : thinternationnal



DirectuX
17-11-2019, 00:21
Hi,

I wrote a tiny tool to help i18n usage.
There is left one adjustment for it to start working :
I18N.GetText seems to not accept key="some key with spaces" although it is valid xml.

All comments welcome.

10092

Petr Schreiber
18-11-2019, 22:35
Hi Sebastian,

I checked the sources and a looot of work went into this effort.

Maybe you could explain more in your first post what is the goal of the tool, please?
I think it will inspire others to try it :drink:

I must admit I am not sure if I use the tool correctly at the moment, however, I found out:
- TestFile2.tbasic contains redundant NEXT
- if you want one file get included just once, you can use #include once
- you could aid installation of the tool like:



' Save as install.py where README.txt is
uses "file", "ini", "console"


string toolsDir = APP_Path + "thinAir\Tools\"


print "Installing binary..."
string newBinary = InstallToolBinary(toolsDir)
if FILE_Exists(newBinary) Then
printl "OK" in 10
else
printl "Failed" in 12
waitkey
end if


RegisterToolBinary(toolsDir)


printl "Installation finished, restart thinAir please!" in 14
waitkey


function InstallToolBinary(toolsDir as string) as string
string newToolDir = toolsDir + "thinternational\"
dir_make(newToolDir)
string fullDestPath = newToolDir + "I18N.exe"
file_copy("bin\I18N.exe", fullDestPath)

return fullDestPath
end function


function RegisterToolBinary(toolsDir as string)
string toolsConfigFile = toolsDir + "thinAir_Tools.ini"

ini_setKey(toolsConfigFile, "thinI18N", "Menu", "thinternational")
ini_setKey(toolsConfigFile, "thinI18N", "CommandLine", "%thinAirinstallpath%\Tools\thinternational\I18N.exe ""%sourcecodefullpathname%""")
ini_setKey(toolsConfigFile, "thinI18N", "SaveScriptBefore", "true")
end function



Petr

DirectuX
18-11-2019, 22:59
Hi Petr,

Thanks for the install script. It's too soon for this tool but will definitely be of use some day.

About TestFile2.tbasicu , it's just here to provide a sample text to parse for the tool to create the XML file. And, I can't find this redundant NEXT.

The tool itself: it generates the translation xml file by parsing the code. But, I can't get (https://www.thinbasic.com/community/showthread.php?12988-thinternationnal&p=95159&viewfull=1#post95159) the I18N module to read keys that contains spaces.



Hi Sebastian,

I must admit I am not sure if I use the tool correctly, however, I found out:
- TestFile2.tbasic contains redundant NEXT
- if you want one file get included just once, you can use #include once
- you could aid installation of the tool like:



' Save as install.py where README.txt is
uses "file", "ini", "console"


string toolsDir = APP_Path + "thinAir\Tools\"


print "Installing binary..."
string newBinary = InstallToolBinary(toolsDir)
if FILE_Exists(newBinary) Then
printl "OK" in 10
else
printl "Failed" in 12
waitkey
end if


RegisterToolBinary(toolsDir)


printl "Installation finished, restart thinAir please!" in 14
waitkey


function InstallToolBinary(toolsDir as string) as string
string newToolDir = toolsDir + "thinternational\"
dir_make(newToolDir)
string fullDestPath = newToolDir + "I18N.exe"
file_copy("bin\I18N.exe", fullDestPath)

return fullDestPath
end function


function RegisterToolBinary(toolsDir as string)
string toolsConfigFile = toolsDir + "thinAir_Tools.ini"

ini_setKey(toolsConfigFile, "thinI18N", "Menu", "thinternational")
ini_setKey(toolsConfigFile, "thinI18N", "CommandLine", "%thinAirinstallpath%\Tools\thinternational\I18N.exe ""%sourcecodefullpathname%""")
ini_setKey(toolsConfigFile, "thinI18N", "SaveScriptBefore", "true")
end function



Petr

Petr Schreiber
18-11-2019, 23:00
One more tip - the thinTool does not have to be binary!

You can keep just the script and in the INI file use thinBASIC to launch it. I think it is better practice, because users can check it does not do anything... bad :)


Petr

P.S. I will consider to convert thinClippy to be tool with visible source as well

DirectuX
19-11-2019, 16:35
Hi,


One more tip - the thinTool does not have to be binary!

You can keep just the script and in the INI file use thinBASIC to launch it. I think it is better practice, because users can check it does not do anything... bad :)


Petr

P.S. I will consider to convert thinClippy to be tool with visible source as well


How does your command look like in thinAir_Tools.ini ? I can't get the script running without bundling.

Then, there is something weird :
if I enclose %sourcecodefullpathname% with double quotes (like this : "%sourcecodefullpathname%" ),
and then check the parameter with File_exists, I get always a %False result (although the path is correct).
But if I didn't enclose it with double quotes, I get %True when there is no space in path,
and path with spaces won't work (normal).
Any Idea why File_exists return %False ?
"Maybe you could explain more in your first post what is the goal of the tool, please?" Petr, I can't edit the first post any more (like you do with BTB). I would have it done otherwise.
I updated the readme.txt
New version, functional this time : 10093

DirectuX
19-11-2019, 16:37
Hi,

Eros , I18N.Gettext() do trim$ the text. Can you tell how I can avoid that ?

DirectuX
26-11-2019, 12:42
Latest version of thinternational can be found here : https://github.com/DirectuX/thinternational

Petr Schreiber
02-12-2019, 11:11
This project has great potential to help a lot of people here with internationalization.

I just wonder how to make the setup/use more "plug and play".


Thank you for your work,
Petr

DirectuX
02-12-2019, 12:14
I just wonder how to make the setup/use more "plug and play".


:D Quite simple : ask Eros to include it in the distribution.

but: I still didn't found how you do to run scripts from the user tool menu , it didn't work here: i have to bundle it for that.

Petr Schreiber
02-12-2019, 12:47
I got it working. Minimal example follows:

- save this as "hello.tbasic" in "thinBasic\thinAir\Tools\MyScript"


uses "os"


msgbox 0, "I process " + OS_GetCommand(2)


- edit the "thinAir_Tools.ini" with this:


[MyScript]
Menu=MyScript
CommandLine=%thinbasicinstallpath%\thinbasicc.exe "%thinAirinstallpath%\Tools\MyScript\hello.tbasic" %sourcecodefullpathnameext%
SaveScriptBefore=true



After you restart thinAir, it should launch the script which is aware of the file.


Petr

DirectuX
02-12-2019, 13:33
I got it working.
Petr

Thanks Petr,

I appended the instructions to the repository (https://github.com/DirectuX/thinternational).