FinalForEach / Cosmic-Reach-Localization

Language translations and localization utilities for the game Cosmic Reach
MIT License
36 stars 89 forks source link

Add a language/localization JSON schema #136

Closed kubikaugustyn closed 2 weeks ago

kubikaugustyn commented 1 month ago

I have created a language/localization JSON schema for those who use an IDE that supports JSON schemas. It will need to be maintained and updated every time a new property/language string is added, see __HOW_TO_ADD_PROPERTY__ for more information on that.

kubikaugustyn commented 1 month ago

The schema, if updated with every addition of a new string, can help people that use IDEs supporting JSON schema determine whether a new string has been added and/or removed and act accordingly - change the localization in their language.

FinalForEach commented 1 month ago

How would IDEs detect the language JSONs use that schema in particular? Could you give an example with how you set it up for yourself specifically?

kubikaugustyn commented 1 month ago

I personally use PyCharm Professional for these kinds of stuff, but I can say all IntelliiJ products support JSON schemas. You can check a guide for IntelliJ IDEA (works on Community Edition which I also use) on how to add a custom JSON schema. These also exist for WebStorm and PyCharm and more IntelliJ IDEs as well (they're the same process). I'll show it here specifically for Cosmic Reach though:

Step 1 - open the schemas popup

image

Step 2 - open the custom schemas settings

image

Step 3 - setup the Cosmic Reach localization schema

image

Step 4 - click OK, it should now show after re-doing step 1

image

Step 5 - select the Cosmic Reach localization schema for your current file

It will now show it's selected: image

Step 6 - when editing other language files, make sure to also select the proper schema with step 5

Now, although it may seem like it takes many steps to add it, in the end it's pretty straight forward. But, when I am let's say adding new texts to some localization, I can just prepare to write a new JSON entry and trigger the Trigger Suggestions command (hit Ctrl + Space), which will bring up the popup with all the missing fields: image

For VSCode users, which I'm not, you can also add JSON schemas to VSCode according to their documentation.

kubikaugustyn commented 1 month ago

There is also a possibility to use it without setting up the schema in your IDE and just have the IDE detect it, and that is by providing a "$schema" field to every single language file. That would make it possible to not have to register the schema in your IDE.

kubikaugustyn commented 1 month ago

I've added the $schema property in https://github.com/FinalForEach/Cosmic-Reach-Localization/pull/136/commits/863f7b04157243d8956075ed2795222aee921732. I've also experimentally set the property to cs_cz.json. The only thing is I linked it to its future location: https://github.com/FinalForEach/Cosmic-Reach-Localization/tree/master/assets/lang/lang.schema.json and not it's current location: https://github.com/kubikaugustyn/Cosmic-Reach-Localization/blob/Localization-schema/assets/lang/lang.schema.json Feel free to edit the pull request as needed.

FinalForEach commented 1 month ago

I'll take a look at this again after the next update

kubikaugustyn commented 1 month ago

Okay, I'll try to keep maintaining the schema until then within this pull request

FinalForEach commented 2 weeks ago

I just tested it out locally, and there weren't any issues! I'll merge it in now.