Jump to content

how setting languages (countries) into a T3D project


keltwookie
 Share

Recommended Posts

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

Link to comment
Share on other sites

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/official/content/documentation/Scripting/Overview/Introduction.html


I do localization based on the resource posted by the user Manoel Neto in this page:

https://www.garagegames.com/community/forums/viewthread/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 )

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@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:

 

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

Link to comment
Share on other sites

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/remove-bom-with-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.

http://i.imgur.com/KNmIRpr.png


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!

Link to comment
Share on other sites

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:

 

# 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 :)

Link to comment
Share on other sites

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/download/details.aspx?id=6812


Can anybody else confirm this?

Link to comment
Share on other sites

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)) ===|

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Don't download "Visual Studio 2012" - download "Visual Studio 2012 Express".


Or 2013 - https://www.microsoft.com/en-us/download/details.aspx?id=44914


The Express editions are free. Sounds like you're downloading the Pro version, which indeed has to be licensed after 30 days. It will also compile under Visual Studio 2015 Community Edition (also free, and open source), but there are some "slightly-less-than-simple" changes that have to be made because DirectX has been rolled into the Windows SDK and some debugging functions have been deprecated.


And there are other options - they're all a bit more difficult than just using Visual Studio, but they are there: read the wiki and ask questions here (in the Torque3D/C++ forum is best). The engine is written in C++, after all - you can compile it with pretty much any C++ compiler with some tweaking depending on the runtime libraries it depends on - but setting up the "make file" (the file that tells your compiler of choice what order to compile and link) is a process that is fairly complicated (right now, there is a method using CMake described in the wiki). For instance, you'll note that it is possible (with some hammering) to compile T3D on Mac or Linux as well - and VS is not even possible in those environments.

 

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

And that's what I was talking about when I mentioned runtime libraries. The headers that come with Code::Blocks don't define those functions using those names, so you'll have to do some research to see what the equivalent functions/methods are called in Code::Blocks' implementation. It would be best to add conditional compilation based on a preprocessor define so that your changes are used based on the compiler used - this is done for various VS versions and for Apple builds all over the engine.

Link to comment
Share on other sites

Don't download "Visual Studio 2012" - download "Visual Studio 2012 Express".


Or 2013 - https://www.microsoft.com/en-us/download/details.aspx?id=44914


The Express editions are free. Sounds like you're downloading the Pro version, which indeed has to be licensed after 30 days. It will also compile under Visual Studio 2015 Community Edition (also free, and open source), but there are some "slightly-less-than-simple" changes that have to be made because DirectX has been rolled into the Windows SDK and some debugging functions have been deprecated.

Of course I downloaded an 'Express' edition (still updating BTW), and you have to register anyway to obtain the product code to remove the '30 days' stuff....

About the 2013 release: 6,5 GB, no way to download it and the 'wdexpress_full.exe' is an internet install binary,

About the community thing: same case as above: Internet install binary, furthermore, impossible to install it on Win7 32 bits (my current OS), it apparently need IE10 (MS everywhere :roll:)

 

And there are other options - they're all a bit more difficult than just using Visual Studio, but they are there: read the wiki and ask questions here (in the Torque3D/C++ forum is best). The engine is written in C++, after all - you can compile it with pretty much any C++ compiler with some tweaking depending on the runtime libraries it depends on - but setting up the "make file" (the file that tells your compiler of choice what order to compile and link) is a process that is fairly complicated (right now, there is a method using CMake described in the wiki). For instance, you'll note that it is possible (with some hammering) to compile T3D on Mac or Linux as well - and VS is not even possible in those environments.

Will try, but honnestly, I'm very disapointed: Already 1 week I'm stucked with this, what a waste of time !

 

And that's what I was talking about when I mentioned runtime libraries. The headers that come with Code::Blocks don't define those functions using those names, so you'll have to do some research to see what the equivalent functions/methods are called in Code::Blocks' implementation. It would be best to add conditional compilation based on a preprocessor define so that your changes are used based on the compiler used - this is done for various VS versions and for Apple builds all over the engine.

I've already said that I'm not a coder, I have the envy to learn of course, but what you suggested me is to dive deeply into the code.

Well, here are my conclusions: More the time goes, more I hate Kro$oft and I swear Win7 will be the last version of Redmond's products I will use except (in the worst case) via a Virtual Machine with a Debian GNU/Linux hosting

And sadly , and if I can't sort this out quickly I will definitively give up T3D !


Any way, and as for irei1as, many thanks for your time an patience.

Link to comment
Share on other sites

Of course I downloaded an 'Express' edition (still updating BTW), and you have to register anyway to obtain the product code to remove the '30 days' stuff....

About the 2013 release: 6,5 GB, no way to download it and the 'wdexpress_full.exe' is an internet install binary,

About the community thing: same case as above: Internet install binary, furthermore, impossible to install it on Win7 32 bits (my current OS), it apparently need IE10 (MS everywhere :roll:)

Okay, so, dropping a one-off Google email address in a registration page to get a free product is problematic. And using VS2012 Express is problematic. And coding is problematic. And you roll your eyes, apparently :roll: :roll: :roll: :roll: :roll: :roll: . Got it.


So, it looks like this is not the engine for you. Probably better head over and pick up Unity. I'm guessing it has better built-in I18n support anyway.


Welcome to game development!

Link to comment
Share on other sites

Sir,


Really sorry if I'm not sold to MS and if I don't want it more than necessary on my system, really sorry if I spent a year to choose a game engine to finally notice I chose the wrong one (as you said). Indeed, it's the first time I see such a software which need to compile something (except on Linux Oss and it become very rare) before properly using it... Really sorry if I'm not a coder, and really sorry too if I got a low internet connection and if I spent a entire week to downlad>test>download>test>download again, etc... , did read tons of documentations (which appears obsolete the most of the time), without having a viable result.

... Except the last suggestion from you talking about using CMake, and oh miracle, it works !


But honnestly, sir, I confirm: T3D is apparently for an elite group.and I'm thus not concerned anymore (I bet I'm not the only one).


And sir, for your information, Unity is far from beeing the only alternative to T3D, even in the world of open source softwares.:)


I wish sincerely good luck to T3D.

Very Best Regards


~keltwookie


*Dont look for me, I'm already out.*

Link to comment
Share on other sites

But honnestly, sir, I confirm: T3D is apparently for an elite group.and I'm thus not concerned anymore (I bet I'm not the only one).

You are obviously not the only one. Torque isn't for everyone - there is a high learning curve and you have to be prepared to roll up your sleeves. Before you "spend a year" looking for an engine you should have done a bit of research on devmaster.net : http://devmaster.net/devdb/engines - though it is all just opinions - to help you narrow the field before putting time into trying out those you think are most suitable.


Yes, there are many alternatives. Which you choose should be directly related to your ability, especially if you need to "sort this out quickly." I tossed Unity out there (NOT open source, by the way) because it can be run on many more platforms than Torque and because it probably has better language support (as I said when I recommended it) - which was the whole basis of this thread.


Well, the real question is: Are you looking for open source, or are you looking for free? Do you really need to modify the source - and if you do, do you know how? As Keltwookie has discovered, your ability to complete a task does not have any bearing on whether the task is necessary or not. To build a house you must have certain skills - the fact that you don't have those skills and still need to build a house does not make those skill requirements go away.


Yes, these days most game engines come with a pre-compiled executable. So does this one. If you change source code you MUST recompile. In ANY engine. However, changing scripts is no big deal - Torque recompiles scripts on load. How other engines handle this varies.


To continue the construction analogy, to say that you don't want to use a hammer from brand X because there are requirements and would rather use a rock because you don't have to accept those requirements is silly. One should always try to use the best tools available to do the job, and as much as everyone hates it Visual Studio is about the best IDE out there. Working with inferior tools makes it harder to achieve the same quality at the end of your path - yes, you can drive a nail with a rock but a hammer is much better.


And since this is a free and open source engine it meets many peoples' requirements. Additionally, I'm not going to try to sell it to you - if it's not for you then that's just the way it is. Just remember - the next time you ask a question, don't get mad when the answer doesn't suit your expectations. Some things are just not simple and wanting them to be won't make them so.

Link to comment
Share on other sites

I would also note that while @rlranft is right that any changes the source code will necessitate SOME kind of recompile, you can also download the precompiled binaries from the last major release via the wiki, here: http://wiki.torque3d.org/main:downloads#toc4


That'll have the exe already and you can using the scripts and gui/world editors to work on stuf/test stuff out before needing to worry about diving into the source code.


Given that the internationalization stuff seems to mostly operate out of the script/gui editor side, the precompiled binaries should be sufficient to at least test things out.

Link to comment
Share on other sites

Sheesh - now I am curious enough to actually start fiddling with this. I know there was that one guy (the dude with the pig avatar) who managed to get his game working in Chinese, but I don't know how much of that was "screw it, I'll just use my own bitmaps" and how much was "hmm, I think I can actually use localized text."

Link to comment
Share on other sites

Let me confirm that Chinese do work with the c++ change and a localization.

But it needs a bit of more work as arial fails for chinese.


I first added msmincho.ttc (ms mincho, a chinese font, I think) to the font folder in core.

Then I added this new profile:

singleton GuiControlProfile(GuiTextProfileChi : GuiTextProfile)
{
  fontCharset = "CHINESEBIG5";
  category = "Extra";
  fontType = "msmincho";
  fontSize = 20;
};

 

I made sure this thing is loaded before the exec() of the gui that uses it and after the singleton of GuiTextProfile.


Then in the GuiTextControl I changed the profile to that GuiTextProfileChi.

Also to that GuiTextControl I pointed textID = "line_chinese";

line_chinese is defined in the chinese.txt like:

_linezero = _
line_chinese = 中國哲學書電子化計劃
line_b = dos line

Then just loaded chinese.txt as I explained in a previous post.

http://i.imgur.com/O8HKw0M.png


Now, it may be a bit hard to properly switch languages if you need two different profiles.

I guess I could use a common single font with full support for all the languages.

But I think the best method would be to switch profiles in the OnWake callback if the language needs it.

Link to comment
Share on other sites

@irei1as - From your screen shot it looks like you can use both English and Chinese text at the same time. Did you mean mixing languages in the same control? If so, then perhaps an extended MLText control would do the trick - it would have to be extended to add markup for switching fonts mid-sentence and support for using the indicated profile for the contents of the tag. A very interesting idea. I'm (sort of) interested in making a mixed language "game" (actually, an educational game aimed at helping me and others learn Korean) so now that my curiosity is piqued I might just have to start fiddling with this after I finish the stuff I have planned for the RTS Prototype/AI Tutorial.

Link to comment
Share on other sites

Also did you mean to use traditional characters? Because that is what you use right now. Traditional Chinese characters are used on Taiwan and in Hong Kong but not official in mainland China.


China uses the simplified characters. Just to make sure you know that.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...