Support for translations?

Open-source port of PoP that runs natively on Windows, Linux, etc.
Post Reply
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Support for translations?

Post by David »

There are some requests to make texts in SDLPoP translatable.

On GitHub: https://github.com/NagyD/SDLPoP/issues/130 (by raz0rknaif and maxlefou)
And in the forum: viewtopic.php?p=23093#p23093 and viewtopic.php?p=23094#p23094 (both by YURA)

I support the idea, but...
My main concern is the font and the encoding.
Currently, the fonts in SDLPoP contain only ASCII characters, but most languages need characters outside ASCII.
Also, the current text/font system, which is inherited from the DOS version, supports only encodings with 1 byte/character.
And then there is also the problem of who will make the glyphs for the new characters.
Maybe it would be better to use some existing (TrueType) font that covers much of Unicode?

Also, what toolkit to use? raz0rknaif mentioned gettext.
I haven't used it yet, but I could try.

What do you think?
Maybe we should make the game translatable first, and only then worry about non-ASCII characters?
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: Support for translations?

Post by Norbert »

David wrote: March 30th, 2018, 12:21 pmWhat do you think?
I've only done i18n for web apps, but...
You probably want either Noto or GNU Unifont, because both cover most/all of the Unicode Basic Multilingual Plane (BMP).
Noto's Mono variant, for example, appears to cover 233 regions at only 69.9 KB. (Very impressive, if true. :shock:)
This can then be used with SDL_ttf and gettext.
Falcury
Calif
Calif
Posts: 565
Joined: June 25th, 2009, 10:01 pm

Re: Support for translations?

Post by Falcury »

David wrote: March 30th, 2018, 12:21 pm Maybe it would be better to use some existing (TrueType) font that covers much of Unicode?
...
Maybe we should make the game translatable first, and only then worry about non-ASCII characters?
Yes, the issue of non-ASCII characters would undoubtedly come up quickly, when the game becomes translatable...

Some questions that come to mind, regarding using TrueType fonts:
  • Would we need to pick a TrueType font that very closely resembles the original font? And is there even such a font?
  • I wonder if text characters should then be rendered at a higher resolution, e.g., the native monitor resolution (because the number of pixels available at 320x200 may not be enough to render some of the special characters acceptably)?
By the way, what about the texts in the title images?
David wrote: March 30th, 2018, 12:21 pm Also, what toolkit to use? raz0rknaif mentioned gettext.
I haven't used it yet, but I could try.
I'm not familiar with gettext, but after reading a bit about it I think I'm not going to like it, personally. (Mostly because of its bloat, and the apparent depth of its rabbit hole.)
Maybe better to create our own functions for retrieving the translated strings.
We would not need to deal with locales, an INI option to change the language would suffice, I think?
Norbert wrote: March 30th, 2018, 8:41 pm This can then be used with SDL_ttf
Yeah, for rendering, SDL_ttf is probably fine. According to its documentation, it acts like a wrapper for FreeType.
A possible alternative could be stb_truetype.h. (Far smaller footprint; but, not as optimized and full-featured as FreeType.)
YURA
The Prince of Persia
The Prince of Persia
Posts: 1425
Joined: February 9th, 2017, 11:12 pm

Re: Support for translations?

Post by YURA »

I should translate into Russian, throw off the MENU text file. Please.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: Support for translations?

Post by Norbert »

Maybe we could start by searching two TrueType fonts that look like, and can thus emulate, 04B_03 (the menu font, hc_small_font) and font/*.png (the game font, hc_font). There's a 04B_03.ttf, but we'd need a font file that includes non-western characters. Then, if the SDLPoP environment is set to non-English, draw_text() could forward requests to draw_text_ttf(), which could use SDL_ttf and our own written-from-scratch gettext() to retrieve the translated text. We could check if textstate.ptr_font is &hc_font or &hc_small_font, output to textstate->current_x/y, emulating the colorid, etc.

NotoSans-Regular.ttf here is 544KB, is "for writing in all modern and ancient languages", for "855 languages, 236 regions", and looks all right to me. Should be acceptable as both the menu and game font.
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Support for translations?

Post by David »

Here is my first attempt at using TTF fonts: https://github.com/NagyD/SDLPoP/commit/ ... c610a0cae2
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: Support for translations?

Post by Norbert »

David wrote: December 23rd, 2022, 9:47 pm Here is my first attempt at using TTF fonts: https://github.com/NagyD/SDLPoP/commit/ ... c610a0cae2
Unfortunately, TTF_SetFontWrappedAlign (2 no page yet) is only available as of SDL(2)_ttf 2.20.0. Many Linux distros, including Mint, rely on the latest LTS (long-term support) repositories of Ubuntu. Ubuntu's latest LTS is 22.04 (Jammy Jellyfish), released 21 April 2022, and its package for libsdl2-ttf-dev is the older 2.0.18. I've not yet looked at what could be a suitable workaround. By the way, LIBS in Makefile will need SDL2_ttf.
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: Support for translations?

Post by David »

Norbert wrote: December 24th, 2022, 10:54 am By the way, LIBS in Makefile will need SDL2_ttf.
Added: https://github.com/NagyD/SDLPoP/commit/ ... 8c906090d3
Post Reply