Raydium 3D Game Engine

Official forum for everything about Raydium, ManiaDrive, MeMak, ...
It is currently Thu Mar 28, 2024 11:00 am

All times are UTC




Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: internationalization
PostPosted: Sat Oct 14, 2006 11:05 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
I open this new thread as the previous was called "mania drive spanish translation" and i imagine that a lot of people will ignore it.

I have finished the internationalitazion of raydium. Currently the game can be directly translatated to spanish (already 100% done), french and italian. More languages can be added with no effort at all.

Also the mni files can be translated (in a different way). However i still need to know which is the english default language code (en_EN, en_GB, en_US???) Since now the mni loader just load the strings according this value. Hmmm, maybe i could add an "else"....

Important, do you think this internationalization has to overwrite the current mania_drive.c file or should we create a new mania_drive_i18n.c file?

Just waiting your responses to do the commit.

Also we need someone with win32 to test this (i can't).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 5:01 pm 
Offline

Joined: Sun Mar 16, 2003 10:27 am
Posts: 404
I can do the win32 test if you give me a like where i can dowlaod the file


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 5:44 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Well all the needed files are currently uploaded in the svn.
So you only need to update your svn copy of raydium.

Then with:
Code:
./odyncomp.sh mania_drive_i18n.c

you will launch the game with internationalization support. Till now just spanish has been translated.

I imagine that you are french, right?. To test french you will have to follow the next steps:

Go to locale/fr/LC_MESSAGES/ and edit mania_drive.po
In the file you'll have to put each "mgsid" translated in its corresponding "msgstr". After you are agree with the changes(not is needed to translate everything), save and exit.
Now compile your translation launching
Code:
./i18n_step_2.sh

All done, ready to try your changes.

remember: DON'T USE i18n_step_1.sh or you'll delete the previous translations.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 7:00 pm 
Offline

Joined: Sun Mar 16, 2003 10:27 am
Posts: 404
Error message in compiler.exe

Code:
E:\RaydiumSDK\ray\mania_drive_i18n.c:7: libintl.h: No such file or directory
failed !


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 8:54 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
hmm, right. I suppose that to compile that file the include file is needed.
Teorically you can get the gettext from here:
http://sourceforge.net/project/showfile ... p_id=25167
Also, this page looks interesting:
http://home.a-city.de/franco.bez/gettex ... 32_en.html

Once compiled, the resulting binary should not need any extra instalation, at much one dll.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 17, 2006 6:58 am 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
(Seems I must update the Win32 SDK ... I'll try to do this ASAP)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 8:47 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Win32 SDK is now updated so that i18n version of ManiaDrive now compiles (as usual, it's available on Raydium's website).

Perhaps vicente can explain us (if possible) how ManiaDrive is chosing its "language" so we can test if it works (and how) under win32 ?

edit: shouldn't we now merge back i18n changes to mania_drive.c ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 9:37 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Well, i'll try.

In the code, in the main function, the lines
Code:
//initializing the internationalization
//setlocale (LC_ALL, "");
setlocale (LC_CTYPE, "");
setlocale (LC_MESSAGES, "");
bindtextdomain ("mania_drive", "locale");
textdomain ("mania_drive");

are forcing the system to translate the LC_CTYPES(hmm, i have noticed that line is useless, ctypes are not translated) and LC_MESSAGES, placed in the "locale" folder, to the "autodetected" locale related to the domain "mania_drive".

So the gettext library search in ./locale/LOCALE-DETECTED/LC_MESSAGES/DOMAIN.mo
In the spanish example, in mania drive, gettext search in
./locale/es/LC_MESSAGES/mania_drive.mo

The mo file is just a compiled version of the po file. Each po file has a lot of pairs. Each pair is composed of one msgid that is the text as is written in the source file, and a msgstr, that is the translated text.

Really i don't know how it works internally, but in linux it works, is a fact.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 5:41 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Ok, thanks a lot. We can hope that there's some magic into setlocale that makes it working the same under win32 ... I'll translate to french and give it a try.

vicente, are you ok to merge changes to "main" ManiaDrive ? (and delete mania_drive_i18n.c then)

Another question: How does it works when we'll need new strings into ManiaDrive ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 7:52 pm 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Ok, i'm ok with that merging (and deleting _i18n verion).

That update was already prepared. When new strings are included we have to :
1- put that strings into gettext: gettext("new_string") instead of just "new_string"
2- launch the update_po script: ./i18n_update_po.sh
That will merge the new strings with the old po files without deleting any content.
3- That's all. The po files are ready to receive the new translations.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 8:13 pm 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
Nice, it's easy ! ;)

(I let you do the merge ... I dunno what's the best : applying last changes from MD to MDi18n or vice versa ?)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 9:25 am 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
Did your french translation worked to you?

Ok, i'll commit the new mania_drive.c today.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 9:58 am 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
It works great under Linux. The must be done with win32 now ...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 10:12 am 
Offline
User avatar

Joined: Thu Sep 29, 2005 2:59 pm
Posts: 828
So in win32 is not working? Hmmm
Well, anyway, GREAT. At least we have linux support for internationalization that could atract more collaborators to the project.

Also i just have done the new commit with the mania_drive.c file internationalizated, the po scripts updated and mania_drive_i18n.c deleted.

About your idea of the implementation of the message(of the circuits) reader with i18n, can you explain a bit more?
Did you take a look the working version thath i passed you a few days ago? The code worked with msg files like this:
Code:
// Messages for beg1.msg

en=[
Welcome to ManiaDrive !
The "beginners" mode will help you to master your car,
so you can play smoothly the "Pro" mode.
];

es_ES.UTF-8=[
Bienvenido a ManiaDrive!
Los Tutoriales te ayudaran a dominar tu coche,
para que puedas jugar bien al modo profesional.
];

fr_FR.UTF-8=[
];

it_IT.UTF-8=[
];

en=[
ManiaDrive offers a challenging gameplay: the car is hard
to control, with complex physics and barrier contacts must
be avoided. The main idea is:
^0Drive clean. Speed will come after.^f
];

es_ES.UTF-8=[
ManiaDrive ofrece un juego muy competitivo: el coche es
dificil de controlar, con fisica compleja. Los quitamientos
deben evitarse. La idea es:
^0Conduce limpiamente. La velocidad vendra luego.^f
];

fr_FR.UTF-8=[
];

it_IT.UTF-8=[
];

en=[
This first track shows how "checkpoints" works:
To complete this track, you must go trough the
blue checkpoint, on the left.
];

es_ES.UTF-8=[
La primera pista muestra como van las metas:
Para completar esta pista, debes pasar por la meta
azul, a la izquierda.
];

fr_FR.UTF-8=[
];

it_IT.UTF-8=[
];

en=[
You must complete this track in less than 20 seconds.
];

es_ES.UTF-8=[
Debes completar la pista en menos de 20 segundos.
];

fr_FR.UTF-8=[
];

it_IT.UTF-8=[
];

In this way you can evade the problems of simplify languages too much with 2 letters. In fact es_ES and es_AR are slightly different (the word "coger" is "take" and "fuck" respectively in each language). Well we could remove the UTF8, that will be always repeated

The interesting part of the code is the ShowMessage function:
Code:
void showMessage(char *file, int id)
{
int handle;
FILE *fp;
int count;
signed char found=0;
int lines[32]; // start index of each line

int ret;
char var[RAYDIUM_MAX_NAME_LEN];
char val_s[RAYDIUM_GUI_DATASIZE];
float val_f[10];
int size;

raydium_gui_window_delete_name("menu");
fp=raydium_file_fopen(file,"rt");
if(fp)
{
 count=0;

 while( (ret=raydium_parser_read(var,val_s,val_f,&size,fp))!=RAYDIUM_PARSER_TYPE_EOF)
    {
    //if(!strcasecmp(var,"en"))
    if(!strcasecmp(var,setlocale(LC_MESSAGES,"")))
   {
        if(ret!=RAYDIUM_PARSER_TYPE_RAWDATA)
       {
       raydium_log("message is wrong type, must be RAWDATA.");
       continue;
       }                     
   if(count!=id)
       {
       count++;
       continue;
       }

   found=1;
   break;
   }
    }
 fclose(fp);
} // fp was ok


if(found)
    {
    int nlines=0;
    int i;
    int start=0;
    int len;
    float width;
    float heigth;
    int mx;
   
    len=strlen(val_s);
   
    mx=0;
    for(i=0;i<len;i++)
   if(val_s[i]=='\n')
       {
       val_s[i]=0;
       lines[nlines]=start;
       if(strlen(val_s+start)>mx)
      mx=strlen(val_s+start);
       start=i+1;
       nlines++;
       }

    width=mx*1.6;
    heigth=(nlines+2)*5;
   
    if(width<20) width=40;
   
    handle=raydium_gui_window_create("menu",((float)100-width)/2,((float)100-heigth)/2,width,heigth);
    raydium_gui_widget_sizes(0,0,18);
    for(i=0;i<nlines;i++)
   {
   sprintf(var,"lbl%i",i);
   raydium_gui_label_create(var,handle,50,100-((float)100/(nlines+2))*(i+1),val_s+lines[i],0.2,0,0);
   }

    // create button here
    sprintf(var,"btnMessageOk;%i",id+1);
    raydium_gui_widget_sizes(15,5,18);
    id=raydium_gui_button_create(var,handle,40,100-((float)100/(nlines+2))*(i+1.5),"OK",btnMessageOk);
    raydium_gui_widget_focus_name(var,"menu");
    raydium_gui_show();
    }
else
    {
    trackdata.message_file[0]=0;
    raydium_osd_cursor_set(NULL,0,0); // hide mouse cursor
    raydium_gui_hide();
    }
}

Well, i remember that the "en" messages was not supported yet in my version :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 20, 2006 11:35 am 
Offline
User avatar

Joined: Sun Mar 16, 2003 2:53 am
Posts: 2591
Location: gnniiiii (Scrat)
A few things:
- I dunno if win32 is working :) The test must be done (one word is missing in my last message).
- I read your code about i18n messages ! :)
Problem are :
- we must use langages like "en", "es", "fr" and so on ... (es_ES.UTF-8 means that we must wrote 10 translations for only one language [es_ES.ISO-8859-1, -15, ...])
- when current locale is not available, we must fallback to a default ("en")

I'll try to apply all these changes quickly :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 34 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group