Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Adding multiple languages to an existing AGK app

Author
Message
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 9th Sep 2019 15:28
What would be the best solution/method for adding multiple languages to an existing AppGameKit app that is pretty text heavy? I can only really think of a text/csv file, and maybe one for each language that has a line for each bit of text and a key/variable at the beginning of the line. So for example if I wanted to show different languages for Hello World I'd add a line to each language file like this:

EnglishLanguage.txt
HelloWorldText=Hello World

FrenchLanguage.txt
HelloWorldText=Bonjour le monde

I'd then read that file in and store it in arrays or something so that I can later call the relevant text by searching for HelloWorldText.

A CSV file could have each language in its own column i.e.

Key,English,French
HelloWorldText,"Hello World","Bonjour le monde"

It seems like it could get messy quite quickly with the above approaches. Coming up with unique key names would be a pain, and some would be quite long I'd imagine. I also see a problem with text that has substitution in the middle of the string for example:

"Welcome " + usersName$ + " to my cool app."

I obviously don't say 'welcome to my cool app' in my app but I do have a fair bit of substitution in the middle of a strings similar to the above example.

Does anyone have apps that work with multiple languages differently? I suspect any tips shared here would be useful to a much larger group of developers, and not just me
OryUI - A WIP AGK2 UI Framework
SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 9th Sep 2019 15:58
I use an external text file with the array indexes built in line by line. Then once in game, I just call the same 'textline$' array variable with whichever index value is needed for the required line of text. Some lines are partial if a value needs to be inserted in between. I then use 'rem' lines with the English baseline above where each text line is used to keep track and help with searching. So the text file looks like:

1=GameName
2=Welcome to
3=Select Mode

And so on. Then just the text itself needs to be changed for each index for each language. Switching languages is as simple as loading the alternate text file and inserting each line into its specified index. An example in practice: https://play.google.com/store/apps/details?id=com.SW3DG.ArvochCommand and the language can be changed in the Options menu with the game running after installation.

It's best to plan something like this in the early stages of development as having to do it afterwards with strings already assigned can take quite a while to change/edit for a customizable text file structure.
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 9th Sep 2019 17:16 Edited at: 9th Sep 2019 17:24
I did this a couple of years ago and came up with the following method which worked very well:
I wrote a text file file in English with each phrase on a different line and a #constant to reference that line in an array. For example:

Text file:
Quote: "
Welcome to my app
Hello world
It is [Player names] turn
"

When passing this to the translators, you tell them to treat each line as a separate phrase and ensure they stay in the same order but most importantly, you tell them not to translate anything inside square brackets but to move the square bracketed word within the translated phrase so that it still makes sense.
You then deal with the square brackets in code.

You can then say:


If it helps, I got all of my translations from https://www.fiverr.com/
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 9th Sep 2019 17:31
Thanks Scraggle. For a text heavy app I'm worried that it would need quite a lot of constants, and moving one line in the text file would cause everything to go out of sync. I know the point isn't to insert or remove lines to/from the middle of the list but it could definitely happen.
OryUI - A WIP AGK2 UI Framework
Scraggle
Moderator
20
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 9th Sep 2019 17:56
In that case I would write the file in Excel with English in the left column and each translation along-side it in further columns. Then if any line has to move you can move all of the translations at once.
Save the spreadsheet as a CSV and you can load just the language you need from an offset of the CSV.
To avoid the heavy #constant list, you can use the row number from the spreadsheet as an array reference for each translated phrase.
SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 9th Sep 2019 18:15 Edited at: 9th Sep 2019 18:17
One of the reasons I use built in numbers and just read those for indexes is so I can do things like include rem lines/instructions/notes/spaces in the text file itself. You can also move things around and even change their order and things still work. The loading routine for the text file is something like this:

adambiser
AGK Developer
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 9th Sep 2019 19:52 Edited at: 9th Sep 2019 20:28
What about using JSON files?



Then the language files look like:

or with the hard-coded variable names (ParseTextHC):
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 10th Sep 2019 09:04
Thank you for your solutions. I might look at using CSV for the translators to fill in and possibly convert it to json. Whether that be a multidimensional array that contains all languages or just the single language needed. The latter being simpler.
OryUI - A WIP AGK2 UI Framework
AliceSim1
5
Years of Service
User Offline
Joined: 15th Oct 2018
Location: Barcelona
Posted: 10th Sep 2019 10:44
Interesting multi language implementation tips, in a txt file ...
Using an ID name to locate the line of text to be printed is a good idea, rather than using an index number.
for future updates when inserting, moving or deleting a line of dialogue.
using an ID name, it is better than not an index number (a number can be confusing and more difficult to locate between more lines)

Login to post a reply

Server time is: 2024-04-20 16:59:12
Your offset time is: 2024-04-20 16:59:12