Page 1 of 1

Translations

PostPosted: 18 Mar 2017, 11:45
by GunChleoc
Any plans on making this game translateable?
Since Freeciv has been translated into many languages, the translation effort itself should be fairly small.

Re: Translations

PostPosted: 18 Mar 2017, 14:37
by AndreasR
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?

Re: Translations

PostPosted: 18 Mar 2017, 15:24
by onpon4
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.

Re: Translations

PostPosted: 18 Mar 2017, 20:06
by GunChleoc
Maybe the Translate Toolkit converters can help?

http://docs.translatehouse.org/projects ... index.html

Re: Translations

PostPosted: 17 Jul 2017, 20:15
by palrogg
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...