how setting languages (countries) into a T3D project

There are no stupid questions, just stupid answers.
28 posts Page 1 of 3
keltwookie
Posts: 8
Joined: Sat May 07, 2016 1:09 am
by keltwookie » Sat May 07, 2016 1:15 am
Hello all

First of all, thanks to all the community here to provide us such tool of creation under open source/MIT license,...and sincere apologies for my English (really not sure it is one of the bests).

Having downloaded Torque 3D since a few months and played a bit with, I started to work on a game project with a friend few weeks ago.
Of course, I develop it in English but I would set other languages (like French, German, Spanish, etc...)
On several games I modded before (essentially Freelancer + X3TC), texts in scripts are replaced by ID numbers which I find usefull to set other languages.
My question is: Is there a way (for dummies) or another to implement this into a T3D project?

I tried this: How to make an internationalization support on Torque?
But the problem is I don't know how loading a defined language.

Thanks by advance
irei1as
Posts: 84
Joined: Fri Feb 27, 2015 5:13 pm
by irei1as » Sat May 07, 2016 5:40 pm
Localization is outdated in the current code as it lacks some old programs.
You can read how it worked if you look for "localization" in the "TorqueScript Reference Manual".
The TorqueScript Reference Manual is a must to have anyway so get it if you don't have it already. The official one (I think) is in here:
http://docs.garagegames.com/torque-3d/o ... ction.html

I do localization based on the resource posted by the user Manoel Neto in this page:
https://www.garagegames.com/community/f ... ead/114207

It works with the actual code very well. If you want to check an example you can try this small game:
https://irei1as.itch.io/1t

(My documentation on how to use: http://pastebin.com/buMu4cmM )
rlranft
Posts: 309
Joined: Thu Feb 05, 2015 3:11 pm
 
by rlranft » Sat May 07, 2016 6:27 pm
Oops - looks like @ irei1as beat me to the punch with a (probably) better solution, but here goes:

At a glance, it looks like Pat Wilson was saying that you have to have a set of scripts with your desired languages prepared, use globally defined constants for your text entries, then at runtime determine the desired language and load the appropriate set of scripts:
// for example - in /scripts/I18N/English.cs you could define
$I18N::Scene01DlgFrank = "That is a dog.";

// and in /scripts/I18N/Korean.cs you could define that as 
$I18N::Scene01DlgFrank = "그곳은 개입니다.";
Then in one of your preferences files just add a define for desired language:
// in /scripts/client/prefs.cs you could add
$Pref::Language = "Korean";
Next, you'll want a set of GUI profiles that use the desired fonts. This is general UI stuff, and you could conditionally load them the same way as your language text strings - just copy the existing profiles into folders by language and then modify each set appropriately - then load them using similar logic to below (though you're going to want to find where profiles are loaded and do this there).
And then check this in /scripts/client/defaults.cs:
// tiny file, modify to match this:

// Finally load the preferences saved from the last
// game execution if they exist.
if ( $platform !$= "xenon" )
{
   if ( isFile( "./prefs.cs" ) )
   {
      exec( "./prefs.cs" );
      // I'm just echoing for test here
      echo(" -- loading language defines for " @ $Pref::Language @ "....");
      // but you would use this (assuming your language text define file matches the language name)
      exec("scripts/I18N/" @ $Pref:Language @ ".cs");
   }
}
else
{
   echo( "Not loading client prefs.cs on Xbox360" );
}
So, that's my oh-so-brief understanding of Pat Wilson's idea (and I could be way, way off).
Now, before we actually head down this road, Torque has "UTF-8 support" so it should handle UTF-8 character representations correctly. UNICODE, not so much I think. I have seen forum threads in the past (on the old GG site) on this topic and it seemed very painful.
keltwookie
Posts: 8
Joined: Sat May 07, 2016 1:09 am
by keltwookie » Mon May 09, 2016 10:45 am
Really sorry for late reply and many thanks to both of you,
I began to discourage to find a solution, it has been more or less two weeks since I looked for a way to sort this out.

I try this right now :)

Thanks again
keltwookie
Posts: 8
Joined: Sat May 07, 2016 1:09 am
by keltwookie » Tue May 10, 2016 2:26 pm
@ irei1as

Sorry if I look like a perfect dumb but I tried your methods by several ways (also mixed with what I've learned into TorqueScript Reference Manual) and nothing works. Furthermore, I downloaded your game but I can't compare files as all is in *.dso format, and I can't find a way to read them.

1) I edited the sources with C++ code (first time in my life I do this) as indicated here:
http://pastebin.com/buMu4cmM

2) What next exactly? I'm sorry but it's not clear for me. On part 5 it is witten:

Code: Select all

Create a "english.txt" in game/scripts and make its text: "txt_hello = Hello world txt_language = This is the english language txt_last = This is the last string You may want it to be UTF-8 without BOM...
Does it means that I have to create the project first, and then create the needed files and edit them? Or doing this into the template files (empty/full) and creating the project after.
I also checked other resources and they talk about a *.cs file (as rlranft did), not a *.txt one. And yes, I would want to set texts as UTF8 to support non-european languages like russian, chinese, etc... but what is 'BOM'?

Another point is that no *.lso files appears anywhere, same thing about a LanguageMap.cs file, and If I understood correctly, these files would be created once the project be created after having edited the sources, correct?

Sorry again but I'm not a coder and what could appear obvious for skilled persons appears totally nebulous for the beginner I am.

EDIT: The purpose is obviously to set languages for my project but also to write a complete tutorial for Frenchies here
irei1as
Posts: 84
Joined: Fri Feb 27, 2015 5:13 pm
by irei1as » Wed May 11, 2016 5:20 pm
Any kind of project to check the changes is alright. Using empty or full template is fine. You may want to use the project you're using to make the gui that is going to be localized.
The folder "game/scripts" is just an example so it may change for other kind of templates. You can use other directories if you want, of course.

Those files being txt is because they aren't torquescript files, just the text. After doing all the text, running the program and obtaining its .lso and the languagemap.cs you can delete the txt for its release (I didn't release the txt files). Err, remember to save the original files somewhere for if you want to make updates after the release, of course.


To remove the BOM (byte order mark) is easy with notepad++:
http://www.larshaendler.com/2015/01/20/ ... h-notepad/
If you leave the BOM (a few bytes at the start of a text file) the program may not read the line correctly. But it may still work if the first line is something like:
first_line = Not used first line.
And you just don't use it.

Notepad++ is a freeware text editor with a very good support for a lot of languages (I know it works for English, Spanish and Japanese, for example). It's quite useful for coders, too. I particularly use a lot its "find in files" option for the torque 3d code. I recommend it.

So, let me point what it's supposed to be done:
1- Change the c++ code
2- Create a new project. Full template is a perfect start.
3- Compile the new exe with the changes made at the start for that new project.
The way to compile the new exe is in the build folder of that new project.
4- In "game/scripts" create all the text files in UTF8 without BOM you want like "English.txt", "French.txt", etc and set its content like told in the pastebin thing.
5- Do the changes to game/scripts/main.cs and game/main.cs as stated.

Note that you have to use the names of the files you made!
If you have English.txt, French.txt and Japanese.txt (for example) you'll need to make a few changes:
compileLanguage("./English.txt", 1); //that 1 exists to create languageMap.cs
compileLanguage("./French.txt", 0); //different line!
compileLanguage("./Japanese.txt", 0); //a new third language!
mainLangTable.addLanguage("./english.lso", "English"); //language #0
mainLangTable.addLanguage("./French.lso", "French"); //language #1
mainLangTable.addLanguage("./Japanese.lso", "Japanese"); //language #2

6- Run the exe (the newly created we did before) and the .lso and the languagemap.cs will be created in game/scripts.
7- In order for the gui to use those languages you have to use the textID field in the gui editor with the name of the line.
Image

You can also change textID with the method setTextID(%textID)
To set a new text for the text gui of the image the console function could be:
TheNamedText.setTextID("story_text_A01");

(story_text_A01 = ... is a line defined in the txt)

8- If the text doesn't change right away use popDialog and pushDialog like said in the TorqueScript Reference Manual for localization.



Sorry if I'm not explaining myself correctly enough. If you still have any issue please don't hesitate to ask and I'll see if I can upload an example or something.
Good luck!
keltwookie
Posts: 8
Joined: Sat May 07, 2016 1:09 am
by keltwookie » Wed May 11, 2016 9:26 pm
Notepad++ is a freeware text editor with a very good support for a lot of languages (I know it works for English, Spanish and Japanese, for example). It's quite useful for coders, too. I particularly use a lot its "find in files" option for the torque 3d code. I recommend it
Yes, agreed, one of my favorite tool and the 'Search' functions are great.
3- Compile the new exe with the changes made at the start for that new project.
The way to compile the new exe is in the build folder of that new project.
I looked into this folders but no indications to compile the *.exe, I searched for other clues and a post said "Torque 3D ReadMe file is your friend" (RTFM style lol), and here's the said file:

Code: Select all

# Torque 3D MIT Licensed Open Source version of [Torque 3D](http://torque3d.org) from [GarageGames](http://www.garagegames.com) ## More Information * [Homepage](http://torque3d.org) * [Torque 3D wiki](http://wiki.torque3d.org) * [Community forum](http://forums.torque3d.org) * [GarageGames forum](http://www.garagegames.com/community/forums) * [GarageGames professional services](http://services.garagegames.com/) ## Pre-compiled Version In addition to GitHub we also have a couple of pre-packaged files for you to download if you would prefer to not compile the code yourself. They are available from the [downloads](http://wiki.torque3d.org/main:downloads) page on the wiki. ## Related repositories * [Torque 3D main repository](https://github.com/GarageGames/Torque3D) (you are here!) * [Project Manager repository](https://github.com/GarageGames/Torque3D-ProjectManager) * [Offline documentation repository](https://github.com/GarageGames/Torque3D-Documentation) # License Copyright (c) 2012 GarageGames, LLC Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Of course, what you suggested is I have to compile the binary myself, correct? If yes, I still don't know how to do this Another thing I don't understand is that I have to re-compile the thing after creating the project. In my mind, creating the project after having editing the files was enough...apparently not.

Thanks for your time and patience :)
irei1as
Posts: 84
Joined: Fri Feb 27, 2015 5:13 pm
by irei1as » Thu May 12, 2016 9:56 am
Ah, you need then Visual Studio.
If you look inside the build folder yuo'll see vs201x folders. Inside those there are files for those programs.

I use WindowsXP in my old computer so I have Visual Studio 2010. After installing it AND (important) the directx sdk I can build it running the .sln file. Well, and then using f7 inside the program.

If you have a newer windows you may want to look for the 2012 version (that's the other vs folder, isn't it).
Be sure you get the freeware version.

I think the directx sdk is
https://www.microsoft.com/en-us/downloa ... px?id=6812

Can anybody else confirm this?
keltwookie
Posts: 8
Joined: Sat May 07, 2016 1:09 am
by keltwookie » Sun May 15, 2016 11:53 am
Sorry for really late reply

Visual Studio 2012:
After 2 days of downloading due to a low iInternet connection (update started 20mn ago and still running while I type this), I notice that you have to create an account on Microsoft to use it more than 30 days (no freeware version found). I'm really sorry, but no way !

Is there another solution? I 've heard a lot about an alternative: Code::Blocks, but T3D apparently don't support it.

EDIT: Here's the compiling message errors I have with Code::Blocks:

...error: '_get_current_locale' was not declared in this scope|
...error: '_swprintf_l' was not declared in this scope|
...error: '_get_current_locale' was not declared in this scope|
...error: '_swprintf_l' was not declared in this scope|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
keltwookie
Posts: 8
Joined: Sat May 07, 2016 1:09 am
by keltwookie » Sun May 15, 2016 2:53 pm
Maybe out of topic but here's what my friend think about this:
Well that does not say a lot for open source development if you have to use an MS product with no other option. What a bummer!!!
To be truthfull I am somewhat dismayed that Torque3D force you down that path. I think I once read that Visual Studio was a result of highjacked software with some dirty programming to make it MS.
Unusual to say that I'm totally agree with that point of view.

T3D is under open source/MIT license since 2012, right? So why still using proprietary softwares, especially if there are open source and free alternatives?
28 posts Page 1 of 3

Who is online

Users browsing this forum: No registered users and 6 guests