Jump to content
  • Advertisement
Sign in to follow this  
Honneamise

help with multi language

This topic is 2950 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

at the moment im in the phase of planning a simple 2d hexagonal strategy game.
nothing new or too complex.

my question it is how to make it multi language .

for general messages it is not a problem.
i can use multiple files in the format :

Quote:

//messages_en.txt
MSG01=hello;

//messages_fr.txt
MSG01=salut;

//messages_it.txt
MSG01=ciao;


depending on the chosen languages i can load the correct files .


but i have some problems with my map .

my map is a pointer to a struct with a matrix of pointers to hex .
Quote:

typedef struct Map
{
char *name;
int w;
int h;
PHex **matrix;
}Map;


typedef Map *PMap;


an hex is a pointer to a terrain struct and a unit struct .
Quote:

typedef struct Hex
{
PTerrain terrain;
PUnit unit;//if unit==NULL no unit on the Hex

}Hex;

typedef Hex *PHex;


and finally for example i have the struct of terrain :
Quote:

typedef struct Terrain
{
int id;
int type;
char *name;//this should be of correct language(es:"city")
char *desc;//this too it is the description(es:"city: offer good defense for infantry troops")

int strenghtb;
int attack;
int defense;
int movement;
int morale;

}Terrain;


typedef Terrain *PTerrain;


the map file i load it is a simple txt file with stored the terrain ID to load for each hex .

the terrain ID it is the associated filename to load with the stats informations for the terrain (strenght,attack,defense,etc..) .

the problem is that i cannot put in this file the name and the description cause i should rewrite the terrain file of every hex for every language .

as solution i was thinking to use a sqlite3 db where to store the informations, but also this is not a good choice because i have to create a different db file for every language .

thanks in advance for any suggestion .

Share this post


Link to post
Share on other sites
Advertisement
Google around for "localization" (or "localisation" [wink]) for some tips.

The method we use is to store all of our text in pages which are just groups of associated lines. (This is a very freeform structure to allow us to store text in any grouping that makes sense; you might find that you need more structure if you have a lot of text, or maybe you can get away with less structure if you have fairly little text.) Each page and line is stored in an XML file, which is loaded at game start based on the user's language settings. Whenever a text string is needed in the game, we look up the corresponding page and ID, pull it out of the file (actually we cache the file in memory using std::maps, but that's just implementation detail; SQLite or something similar is just as useful, especially if you need a more structured storage format), and then go about displaying it as normal.


Hope that gets you started!

Share this post


Link to post
Share on other sites
thanks for the input .

at the moment im thinking to use the solution of multiple tables in sqlite db .

a base table for the data and a separate table for each language .

an example for the tables structures could be :
Quote:

//for the main table
CREATE TABLE unit
(
id int primary key,
attack int,
defense int
);

//for the language description table (unit_en, unit_it, unit_fr,...)
CREATE TABLE unit_en
(
id int primary key,
name text,
description text
);


doing this i could do ( just an example ) :
Quote:

//id will be the unit id we want
SELECT attack,defense,name,description FROM unit,unit_en WHERE id=unit.id AND id=unit_en.id;



ps : this stuff will be fetched at loading time.
we will have an array in memory with all the data stored, the index will be the id of the object ( in this example unit_vector[0] will be the unit with id==0).
we will query the db only one time, when the game load, so maybe load time will be long, but we have no more access to the disk to retrieve data after this.

Share this post


Link to post
Share on other sites
Actually, a different db file for each language might be better, because then you can drop languages in and out without messing with anything else.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!