Translations

Translations

Postby GunChleoc » 18 Mar 2017, 11:45

Any plans on making this game translateable?
Since Freeciv has been translated into many languages, the translation effort itself should be fairly small.
User avatar
GunChleoc
 
Posts: 266
Joined: 20 Sep 2012, 22:45

Re: Translations

Postby AndreasR » 18 Mar 2017, 14:37

Hi! This has been requested several times before, so it is probably time I prioritize this. I have started several times, but never completed it. There are many challenges, such as that the app is in JavaScript. Thanks for the suggestion! Do you have more suggestions?
User avatar
AndreasR
Fcw Moderator
 
Posts: 16
Joined: 14 Mar 2017, 08:14

Re: Translations

Postby onpon4 » 18 Mar 2017, 15:24

Hm... doing a search for "JavaScript gettext", all I was able to find were ways to do it server-side. That would be perfect for Web pages, but for a JavaScript application, that would be SaaSS. It would also prevent users from downloading and running the application locally (though I don't know how practical that currently is).

I suppose one thing you could do is have a JavaScript file assigning all translatable strings to variables that has to be "compiled" with some sort of script which uses gettext (e.g. Python). So you do that once for each language, save them as e.g. "translations-en.js", and then let the user choose which one to use. That way, you wouldn't have to have the server translate on-demand, there would be no SaaSS elements, and it would not hinder the possibility of running the game on a local machine.
User avatar
onpon4
 
Posts: 367
Joined: 13 Mar 2014, 18:38

Re: Translations

Postby GunChleoc » 18 Mar 2017, 20:06

Maybe the Translate Toolkit converters can help?

http://docs.translatehouse.org/projects ... index.html
User avatar
GunChleoc
 
Posts: 266
Joined: 20 Sep 2012, 22:45

Re: Translations

Postby palrogg » 17 Jul 2017, 20:15

So you'd like to do it client-side instead?

Here's something I use:
- a JSON or JS file per language
- load the appropriate language using xhr

Example (better with JSON, but I feel lazy):
{l Code}: {l Select All Code}
// lang.de.js
var lang = {
    greeting : "Hallo",
    town : "Gemeinde",
    in : "in",
    notAvailable : "Keine Daten für "
};

// lang.fr.js
var lang = {
    greeting : "Salut",
    town : "Commune",
    in : "à",
};

// main page, after you loaded the right language:
var sentence = lang.greeting + ' ' + player.name;
// Or with template strings:
var sentence = `${lang.greeting}, ${player.name}`


If you use Python, saving to json is very convenient.

Hope it helps...
User avatar
palrogg
 
Posts: 33
Joined: 13 Feb 2016, 14:26
Location: Geneva

Who is online

Users browsing this forum: No registered users and 1 guest