2
\$\begingroup\$

I need to create a lot of read-only text data. As far as I know storing a lot of data directly in the script is not good, so I need to create a separate json file with ready-made data to load in the game.

But what if this data should be in multiple languages, that's where the question arises. Should I store in the json file the localization table's keys with translations to access the desired field?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Unity has built-in support for storing localization data. Import the localization package from Unity's package manager, and check out the Quick Start Guide.

It supports localization for TextMeshPro, RawImage, and AudioSource.

Populate your localization database, then right-click on the localizable component, and select Localize. Then you can choose the localization asset.

If you need more custom localization, you can use Smart Strings. You can also use Smart Strings to serialize/deserialize classes/structs, although I suspect you took a wrong turn somewhere if you need to do that.

\$\endgroup\$
4
  • \$\begingroup\$ I don't think that using only localization tables I can reach my goal, because I need to have a structures of data that represent a class, so strings with integers and so on \$\endgroup\$
    – Silz
    Commented Apr 29, 2023 at 9:36
  • \$\begingroup\$ If you'd like to know how you can implement that feature, you should post a new question describing that feature in detail. \$\endgroup\$
    – DMGregory
    Commented Apr 29, 2023 at 12:20
  • \$\begingroup\$ @Silz that sounds like you are mixing things. A value of 4 should be the same regardless what language you are using. Game/ Business logic should not be stored in the translation \$\endgroup\$
    – Zibelas
    Commented Apr 29, 2023 at 18:34
  • \$\begingroup\$ @Zibelas I know, but all strings is a part of a class, text itself doesn't make any sence, only visualize information to player \$\endgroup\$
    – Silz
    Commented Apr 29, 2023 at 20:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .