Skip to content

Translation Editor Dev Mode

Justin113D edited this page Jan 24, 2021 · 3 revisions

Translation Editor Dev Mode

While the translation editor is primarily used for translating formats, you cannot translate something that hasn't been created yet! That is what the developer mode is intended for. In developer mode, you can create string nodes, define their key and default value, group them, automatically assign version id's etc. Since the format file is json, you could also create the entire format by hand in a text editor (like we did before, when we still used xml), but using devmode is for most cases a lot easier and requires less button clicks to do something.

Creating a format using devmode

Entering devmode

To enter devmode, head to the settings, and check the "devmode" checkbox. This will switch the application to developer mode. If devmode is checked, you can also check "JSON indentating". If this is enabled, the JSON will have indenting when saved to make it easier readable. Considering the JSON file doesn't need to be looked at at all in most cases, you can disable it and potentially save a lot of file space.

Creating and saving a file

If another format has been loaded before switching, you will need to create a new file. Select "File->New Format" to create a blank format. The first thing you should do is set the Version (which should correspond to the version of your software/game), the target name (A unique identifier for your format) and the language.

To save the file, select "File->Save Format" or "File->Save Format As...", then select a destination to save your file to.

Adding nodes

Nodes can be added via the green (strings) and blue (parents) add buttons. The buttons exist on the bottom of the top-level-hierachy, to add a top-level node, and appear when hovering over a parent node.

The texts inside the nodes can be edited via selecting them and writing new text. As easy as that!

Moving nodes

Each node has a little rectangle on its left, which you can use to drag the node below any other node. To move a node at the top of a parent node, the parent has to be expanded.

The JSON format

In case you are not very fond of the devmode, that's ok! Here is a documentation on how the format JSON structure.

Header

the top level data for the JSON contains as follows:

{
 "Name": "Test Name"
 "DefaultLanguage": "Klingon"
 "Versions": [
   "1.0.0.0",
   "1.0.0.4",
   ...
 ]
 "ChildNodes": [
 ...
 ]
}
  • Name: The format key. It is used to check if a language file belongs to the format
  • DefaultLanguage: The language in which the format was written
  • Versions: Used for version differences. In this case, 1.0.0.0 would have the version index 0, 1.0.0.4 the index 1 and so on.
  • ChildNodes: The tip of the node hierarchy. An array of nodes

The nodes

There are 2 types of nodes:

String nodes

A string node is the fundamental building block of a format, as they will end up in the language files. They store 4 values:

{
 "Name": "Stringnode"
 "Description": "A simple string node!"
 "DefaultValue": "text"
 "VersionID":  1
}
  • Name: The strings key
  • Description: A description of what the text is, to help translate
  • DefaultValue: the default text (in the default language)
  • VersionID: A lookup index for the version, to see when this node was created or last edited. Leaving it out will default to 0

Parent Node

A Parents node purpose is to host more parent nodes and string nodes.

{
 "Name": "Stringnode"
 "Description": "A simple string node!"
 "ChildNodes": [
  ...
 ]
}
  • Name: Name of the parent
  • Description: A description of what the parent contains
  • ChildNodes: The nodes that the parent node hosts

How do i use the .lang and .langkey files?

The resulting files will have the extensions .lang and .langkey. For your piece of software, you need one lang file for each language and one langkey file, all of which correspond to the same format version. The repository has an example project called "language test", which shows you how to use the files.

Structure

The langkey file contains all string keys in alphabetical order. Those need to be loaded into a dictionary/hashmap. Then, any lang file needs to get loaded. To get the value of a key, read the line in the lang file 4 lines ahead (so, the key on line 1 has its value on line 5 in the lang file). This is because the first 4 lines of the lang file contain following meta data:

  1. Format key
  2. Version
  3. Language
  4. Author

After that, the order actual texts start.