multilangage in your game
BlitzMax Forums/BlitzMax Beginners Area/multilangage in your game
| ||
Hi ! How to organize your code to support multilangage At this time, i use global variables like this Notify gMessage_206$ and at the start of the program a function to choose the langage Global gMessage_206$, gMessage_207$ Function Choose_langage (Langage$) select Langage$ Case "Francais" gMEssage_206$ = "erreur" gMessage_207$ = "bonjour" Case "English" gMessage_206$ = "error" gMessage_207$ = "hello" end select End Function But have you a better idea ? (more easy to maintain to evit to create the gMessage_206b$ if i've a new message between 206 and 207 !!!) Thanks for your help. |
| ||
You probably want to use a "localization" module, perhaps something along the lines of : http://brucey.net/programming/blitz/index.php#bahlocale ...and if I could use Search properly, I would also link to some others. |
| ||
I haven't done anything like this, but I would probably go with a string array and a bunch of consts.const MSG_KILLED:int = 0 const MSG_WIN:int = 1 const MSG_LOST:int = 2 const MSG_GOTSHOTGUN:int = 3 global msg_list:string[10] function load_language( filename:string ) ' Load from filename ' stuff it in msg_list endfunction ' Later in the game show_game_message( MSG_GOTSHOTGUN ) |
| ||
All my text is in a Unicode text file. I read this in and display it in-game. This file can then be edited by language specialists and because it's Unicode, special characters, even Cyrillic can be used. |
| ||
How to organize your code to support multilangage At this time, i use global variables like this Notify gMessage_206$ It's probably a better way to organize it slightly different: 1) Use multiple language files 2) make the content something logical: english.txt <206> error <207> hello french.txt <206> erreur <207> bonjour 3) read the strings into an array or something 4) simply print element 206 or 207 -- the language selection at the beginning would have pre-loaded the strings for a particular language, no need to cycle through all the language options each time you need to print something Optionally you could incbin the various language files so you still have a single .exe file |
| ||
...and if I could use Search properly, I would also link to some others. somewhat off-topic, but: I personally have found that it's a *lot* easier to search the forums simply by going to google.com, enter the search terms, and add site:blitzmax.com in the search box to restrict the results to those on this site. A zillion times faster than using the forum's built-in search options, and it also searches the code archives(!!) The only downside is that it's not up-to-the-minute, but so far it's seemed fairly thorough. |
| ||
Hub. my framework has a TGameText type and supporting functions that let's you read in the Unicode text file. You have it right? It doe only read in one language though, the idea being you release different language versions, but the same could could be modified to read in only one language from a multi-language file using xlsior's method easily. xlsior: Totally agree about google, it's faster and better for combo words etc. |