Hi there! There are a few ways of doing it:
- Use TME’s Localization code (it’s JavaScript with a setting that you need to edit a bit)
- Use conditional statements (like your example)
I personally use the first option in my games (See this source code as example - playable here.
I also have a whole chapter on localization in my SugarCube guide.