Author Topic: Internationalisation of text-games  (Read 3667 times)

Offline Nox

  • Level 35
  • **
  • Posts: 738
  • Reputation: +12/-2
    • View Profile
Re: Internationalisation of text-games
« Reply #25 on: December 09, 2009, 07:39:48 AM »
Internationalisation is something that honestly bothers me a lot so...I'd like to ask... one of the things I've been thinking about is fear of having texts decentralized: you have text in templates, you have text in PHP scripts (like messages to play, e.g. "message has been successfuly sent"), text in JS scripts (I mean for example when using AJAX...maybe there's a better way, like have everything to be included into page stored in html or whatever, I don't know actually how to create a really clean JS), text in DB... the DB data might be okey since they're data? But the rest...
Meet us at an IRC irc.freenode.net #bbg as well
Enjoy http://spiritbeacon.noxart.cz/ !

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,133
  • Reputation: +26/-1
    • View Profile
Re: Internationalisation of text-games
« Reply #26 on: December 09, 2009, 08:38:39 AM »
I assume usage of gettext() in the answers below. Arrays might be not as simple.

- PHP - no problem at all, just put strings within _(""), tedious but nothing really scary
- templates - not sure, but these are sore to php files as well, I have seen some tutorial to internationalize some wordpress templates so it should be doable
- JS - do not use JS? :D Lame solution but works for me.
- DB - what type of game you have? In all my strategy games there is not even one field in the whole database that would require it, in my RPG games there are item, monster, quest tables at most. In addition, I keep all item definitions in php file, so I would need to add gettext to it and then rerun the database update (which won't disrupt gameplay since all item IDs would stay the same, I'm doing it already when I fix spelling mistakes in item descriptions).

Judging from my existing games (probably there are some types of games that would not have it such easy, but I can not think of any right now) translation should be fairly easy for singlebyte languages. I'm not sure about performance.


What bugs me are arrays:
$race=array('human','elf',...);

Using simple gettext on long arrays does not sound too smart...
$race=array(_('human'),_('elf'),...);

Maybe using implode/explode first? Like this:
$t=implode($array);
$array=_($t);
$race=explode($array);

Offline Nox

  • Level 35
  • **
  • Posts: 738
  • Reputation: +12/-2
    • View Profile
Re: Internationalisation of text-games
« Reply #27 on: December 09, 2009, 03:55:03 PM »
Thank you
...and sorry! Yes, I meant gettext...I actually never used it, but it really seems better than arrays

As for your list...I was mainly concerned about fragmentation of texts to be translated... you know...

well...yeah, template would be the same as PHP...right
JS - eem....that doesn't work for Nox :)
DB - that should be RPG/strategy hybrid.... I tend to make more complex games, so... em: you mentioned you don't need fields to be translated but you mentioned items, monsters... tables... they doesn't have to be translated? Item names etc? Mine surely would have to be.
It's not really a problem, I could just add language suffixes (name_cz, name_en...), I was rather concerned about the fact than not all texts would be in one place, but I guess in case of DB it might be understandable

You can make a function that would do the dirty work for you :) say...

Code: [Select]
function __($array){
  $result = array();
  foreach($array as $key=>$value)
    $result[$key] = _($value);

  return $result;
}
Meet us at an IRC irc.freenode.net #bbg as well
Enjoy http://spiritbeacon.noxart.cz/ !

Offline Chris

  • Game Owner
  • Level 35
  • *
  • Posts: 2,133
  • Reputation: +26/-1
    • View Profile
Re: Internationalisation of text-games
« Reply #28 on: December 09, 2009, 05:43:17 PM »
- make a "hello world" app with gettext() it will explain you more than words :D
- DB
* in my strategy games I have not even one table with one word to be translated
* in my RPG games I have items (and in future maybe monsters/quest)
* I could make in my case everything in one place (the RPG case), simply because I would run update item DB names :) The only case it would not work is if you stored strings on per-player item table (a very bad idea for other reasons anyway) or if you made one site/world with several languages supported at once (but this is again a bad idea for other reasons, as explained in the remaining internationalisation topics)
- dealing with arrays - well, I meant it opposite, I wanted to make is faster for the poor CPU, not easier for me to code. Calling gettext() each array key is not fast for sure (it has to lookup the translation file each time).

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal