What are the benefits of storing language dictonaries in json files?

1 favourites
  • 6 posts
From the Asset Store
Source File, music and art pack for Android Negotiator
  • The best way to do localization in construct is probably to use AJAX to request a JSON file for the correct language and then AJAX: "On tag completed" -> Dictonary load from Json string (Ajax.LastData).

    I want to switch to this solution because it is easier to have every language in a seperate file, BUT...

    ...I wonder what the real NEGATIVES of just creating a Dictonary in code are. If you have let's say 5 Dictonaries in code and they all contain 30 sentences in a language, does this increase loading times? Or is it bad for general performance? Because text uses only a few kb so I wonder why it isn't a common practise to just put the dictonaries in code and don't load them from json files. I'm curious to see your answers :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • What do you mean by "creating dictionary in code"? You will have to set each dictionary key with an action on the event sheet. If you only need like 5 keys, I guess this solution is fine. But for 30 keys multiplied by 5 languages - that's too much code!

    I want to switch to this solution because it is easier to have every language in a seperate file...

    I actually did this in my first game and regretted it later. When there are a couple of hundreds strings in each file, it becomes really difficult to sync them, you need to make sure that the key names in each file are the same.

    I now prefer putting all translations into a single array.

  • Yeah, thats exactly what I mean by "with code". I have 2 HUGE event blocks with around 70 actions to set all the keys of a dictionary called "language". I only got 2 languages now, but will have more in the future and will switch to json. I was just wondering wether it has a performance impact to have this much more code, which is only running on start of the layout so I'd guess performance impact probably isn't huge.

    Anyway, the array thing seems good but I have already implemented the dictonary in my game on which I am working on since 2019 and it would be a pain to switch to that. So I will prob just load the Json into the existing dictonary and hope for the best.

    I have seen there is also a "download dictonary" action, which supposedly exports the dictonary as json, maybe this works so I don't have to copy it by hand...

  • Since you are loading/populating the dictionary only once at the start of the game, you should not worry about the performance.

    Anyway, the array thing seems good but I have already implemented the dictonary in my game on which I am working on since 2019 and it would be a pain to switch to that.

    Yeah, I also prefer working with a dictionary. But the array is much easier to manage, especially when you have many hundreds or even thousands of translations in the game. I have a template in the Asset Store which converts that 3D array into a single dictionary, extracting only the strings for the current language.

  • My main concern is that construct is not a robust text editor. I'd balk at working with any sort of significant amounts of text from within construct, so I really appreciate the ability to import and utilize project files.

  • My main concern is that construct is not a robust text editor.

    I agree, it's not. It has got much better since early versions, but still nowhere near the convenience of Excel or Google Sheets.

    If I need to add a lot of strings to the array at once, I usually prepare them in Excel and then copy over to the construct array.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)