Need help w/ GM:S external files for localisation

Posted by Phoebii on Aug. 9, 2017, 7:24 a.m.

As I have mentioned in echo #79, I want to translate Sector Six.

I think I'll put all text into the script so it's all in one place.

E.g.:

BEFORE:
draw_text(756-(transition),136,string(equipped_weapons) + " / " + string(weapon_limit) + " weapons placed");

AFTER:
draw_text(756-(transition),136,string(equipped_weapons) + " / " + string(weapon_limit) + tx(" weapons placed"));

And script itself:

/// tx(string)

switch(argument0)
{
   case " weapons placed":
   if global.language == 1
   {
   return " weapons placed";
   }
   else if global.language == 2
   {
   return " blah blah";
   }
}

Much better would be store all strings in an external file with less code, so it would be easier for people who will translate Sector Six.

But I don't what kind of files should I use and how to use them.

Never done anything like it before.

I googled about this and there was nothing useful to me, so I thought I'll ask for advice here.

Comments

twisterghost 7 years, 3 months ago

A pretty common way to do internationalization is to have a big dictionary file of keys and their string values. Probably the easiest way to do this would be a JSON file that GM imports. GM has native json parsing into a ds_map. I use it in Evenfall for speech trees.

Consider the following json:

File: english.json
{
  "message-weapons-placed": "Weapons placed",
  "ui-quit-to-desktop": "Quit to Desktop"
}

File: french.json
{
  "message-weapons-placed": "Armes placées",
  "ui-quit-to-desktop": "Quitter le bureau"
}

Then you load the language file based on the user's language pref, and your translate function takes a string key and returns the value. Pretty simple really. You can also use tokens (something like "{x}") to do in-string values and such.

Hope that helps.

Phoebii 7 years, 3 months ago

Cool, I'll try that.

Phoebii 7 years, 3 months ago

Managed to get it to work with help of a friend.

*external screaming*

Alert Games 7 years, 2 months ago

Wow old blodpost but….

I did what twisterghost is mentioning before. Except I did it in GM8 and parsed a file format I created. … Is there GML for JSON parsing for GM8?…

JSON is my recommendation as well.