Multi language support!


Today I cancelled my office hours because we were supposed to receive a washer & dryer today between some time frame. However, it snowed, and they cancelled the delivery, but I guess they decided to just? Not tell me?? OK, well I got some engine development done anyway.

I spent this morning implementing multi-language support, so now you can add .chalolang files for different languages and they can be changed from within the program at any time.

The template game project also has a language selection menu added.

The biggest challenge here was working with non-ascii text. Technically, the program was passing around Hindi text in normal std::strings just fine, but SFML was having a trouble once it got ahold of those strings. What I ended up doing for now is just adding a converter in my StringUtility to convert between std::string and std::wstring. This seems to work fine, then the MenuManager will now call an alternative SetupText function for UILabel and UIButton objects when the "asciiText" flag is set to false. (Though really I could do some cleanup here. I decided to just make everything "non-ascii-text", which was needed once I implemented multiple language support.)


Secondly, beyond just adding support for unicode text for UI widgets, I also added another type of flag in the program so that, in my menu files, I can add the key of a piece of text instead of hard-coding the text itself. These keys map to a key in the language file, then the MenuManager detects these and swaps them out. I also had to set up a "Suggested Font" flag, which is being added to the config file as well as the selected menu so that when the text changes in a menu it will try to display the text with the proper font (e.g., Noto Devanagari for Hindi). If no language or suggested font is detected when the program starts, it will send you directly to the language select screen. Otherwise, it loads the language and goes to the startup state.


I've also been writing this in such a way that you can have more than one language loaded in at a time. My new LanguageManager class contains a map to store a set of keys (for languages) to a LanguageSet, which stores all the text keys -> text values. "That's weird. Why would anyone need multiple active languages?" - Because of how I like to make my language learning games. I will need this feature when I get to working on Language Arcade, where you will set (1) the language you know and (2) the language you're learning. This way games can be designed in the target language (the one you're learning) but still have help and hints in the language you know. Anyway, I'm just trying to think of features I'll need in Language Arcade to implement in the engine and the template project before actually writing a bunch of code for that project.

Leave a comment

Log in with itch.io to leave a comment.