What is the best way to display bilingual text?

Hello everyone!

I recently discovered Narrat, and I’m incredibly excited about this tool. It offers features that feel like a dream come true for me. This year, I’ve been migrating some old games to different tools, both to enhance my skills and improve my projects, and Narrat perfectly meets my needs in several aspects.

However, I’ve encountered a specific challenge. As a fan and user of ChoiceScript, transitioning to Narrat has been smooth overall, except when it comes to displaying content based on the language selector.

Currently, I’m handling this by creating one label for Language 1 and another for Language 2 whenever there are significant structural differences. For shared content, I use conditionals (if) to toggle between languages. While functional, this method feels repetitive and inefficient. Additionally, I’m finding it challenging to navigate the code, even with comments and tags to separate blocks.

In ChoiceScript, the use of @{Var 1|2} to compactly display content from different variables was always very handy and efficient. I wonder if there’s something similar in Narrat that allows me to achieve the same result in a single line without relying on more complex structures.

I’m still adapting to the tool, exploring it in my free time for a week i think, and I must admit I’ve made some beginner mistakes. My programming experience is very minimal, I do things by insistence and repetition, English is also my third language, so things are very outside my comfort zone. So, rather than persisting with methods that may not be ideal and keep looking for answers that are obvious to someone experienced, I’ve decided to seek help to address this issue.

Thank you for your attention and patience

I don’t know if narrat has something like this built in but it does have options for making it.

using run_js, you can use js ternary but that only handles a true/false condition.

To find out if something is plural, it would be something like (like as in, off the top of my head, eating breakfast, haven’t tested),

 run_js("(variable > 1) ? 'coconuts' :'coconut';")

You could also make your own narrat label/function, something like:

functionName variable array:
return $array[$variable]

Then you can run functionName variable array, having it return values similar to @{}
It’s not as much of a shorthand, but if you are doing more than @{variable "is single" | "is plural" | "Is other"} it would still be shorter than a staircase of if’s.

edit: mistakes, coffee hasn’t hit yet.

1 Like

Hi, Buddy, how are you? I hope everything is going well! :smiley:

Thank you so much for suggesting a potential solution and for addressing my question! As I mentioned, my experience with the tool is quite limited, and I’m still getting used to it. I understand that the interface is intentionally not very intuitive to avoid obvious questions — something I worry I might be doing right now.

The run_js command caught my attention, and I feel that, in the future, I’ll be able to use it more effectively. At the moment, the solution implemented was rather rudimentary. I managed to apply it to small sections, and although it reduced the code size, it wasn’t a significant change. This is because I realized that my text construction logic is also part of the problem. When I adapt everything to better align with the structure proposed for narration and dialogue in Narrat, I can mitigate many of the difficulties simply by reorganizing the format.

The solution I’ve found during this restructuring process was to create a ‘section A’ in English at the beginning of the block and, further down, start a ‘section B’ in a different language, keeping everything in the same document. This approach makes construction easier but significantly complicates the revision process, even flagging. More than once, I missed important information and a correction that was applied in section A ended up being neglected in the section B, which required a correction label for each respective block, making everything an unbelievable mess.

Practically speaking, until I become more familiar with the tool, I understand that the best course of action is to abandon the idea of building something bilingual for now and save the transition to another language for the end, creating a separate version of the game for each language. Since this wasn’t an issue in ChoiceScript, at some point, I lost sight of how much I had adapted the proposed method to make this development habit possible, where during mechanical corrections or consistency checks, I was able to handle everything within a single file and project.

Right now, this is the biggest challenge I’m facing with the tool. I’ve been putting a lot of effort into it, but I believe it’s just a matter of experience, and with time, I’ll find a more efficient way to handle it, just as I did with ChoiceScript, which also isn’t particularly friendly in this regard, and I created a method that worked for me.

Once again, thank you so much for your kindness and the time you dedicated to helping me! I wish you a prosperous day\afternoon\night!

Oh I missed you were doing 2 languages!

You may want to separate logic and text in this case. ${} might have been convenient in ChoiceScript, but mixing logic and text creates the very issues you mentioned facing.

I haven’t done something like this in Narrat. I don’t think Narrat supports localization out of the box, but if I were to do something like that, I’d probably try to implement LocalePlanet: L10N and I18N for JavaScript somehow.

Doing it manually, using only Narrat, I’d probably put all the text into objects (pulled from yaml or json). Then show the text from the object matching the set locale. A custom function or macro could be used to handle displaying the text.

1 Like