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?
Support for translations?
Re: Support for translations?
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. )
This can then be used with SDL_ttf and gettext.
Re: Support for translations?
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)?
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.)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.
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?
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.)
Re: Support for translations?
I should translate into Russian, throw off the MENU text file. Please.
Re: Support for translations?
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.
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.
Re: Support for translations?
Here is my first attempt at using TTF fonts: https://github.com/NagyD/SDLPoP/commit/ ... c610a0cae2
Re: Support for translations?
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 wrote: ↑December 23rd, 2022, 9:47 pm Here is my first attempt at using TTF fonts: https://github.com/NagyD/SDLPoP/commit/ ... c610a0cae2