JSON files

Table of Contents



About

On Pepper&Carrot, you'll meet many JSON files (JavaScript Object Notation). They are our favorite way to store data! It’s lightweight, easy to read, and plays well with almost any programming language. Each item (key-value pair) has its own spot, making data travel smooth and organized.

So, where is the catch? Well, the JSON format is (unfortunately) very strict regarding commas, so we also have an automated tool for testing the JSON files. The check is performed by our CI pipelines when you post a Merge Request. But if you have Python available and prefer to run it locally on your PC, you can run it by calling the script python .ci/validate_json.py.

info.json (translation)

Location

The info.json (translation) files are located inside each two letters "translation directories" of the webcomics repository. Each <episode>/lang/<language> folder should contain an info.json file with translator credits in it.

Eg. in the Hungarian translation of the episode 15:
→ webcomics/ep15_The-Crystal-Ball/lang/hu/info.json

Role

The info.json (translation) files contain information about the translation.

Structure

Here's a minimal example:

{
   "credits": {
      "translation": [
         "MyNameHere"
    ]
  }
}

And here is an example with a translator, two proofreaders and a contributor:

{
   "credits": {
      "translation": [
         "Nartance"
      ],
      "proofreading": [
         "CalimeroTeknik",
         "Valvin"
      ],
      "contribution": [
         "David Revoy <https://framagit.org/Deevad>"
      ]
   }
}

More examples can be found around the project, such as: EN_EP37, FR_EP31, DE_EP31.

Description

  • translation contains everybody who worked on the original translation
  • proofreading is for linguistic fixes and improvements
  • contribution is for layout and technical fixes, title graphics etc.
  • notes is for everything that doesn't fit anywhere else.
  • If you see "translation": [ "original version" ] it means the episode was written into this language (so, no need for translation), David Revoy wrote sometime in English, sometime in French.
  • Links are optional. You can use an http(s):// or mailto: link, they need to be framed by superior/inferior symbols like this: <https://framagit.org/Deevad>.
  • If you are doing a lot of SVG improvements across many episodes and language; it's easier to add yourself to project-global-credits.json at the root of the repository. It contains a svg-database for the heroes ready to work on the maintenance of the enormous database.
  • We also have a template file with all options available to help you get started.

info.json (episode)

Location

At the root of each comic directory (episodes) you'll find a info.json.

Eg. For the episode 15:
→ webcomics/ep15_The-Crystal-Ball/info.json

Role

This file contains extensive information related to the episode itself and is not intended to be altered by translators, as it should remain largely unchanged after the episode's creation. But if you want to know more about them, we also have templates available for these, one containing all permitted keys and one containing only the mandatory keys.

langs.json

Location

The file langs.json located at the root of the webcomic repository

Role

It manages how all the languages are registered in Pepper&Carrot (website, but also external app) and also was used to document the attribution to the translators (now deprecated, but still used by some external app).

Structure

A typical node of this JSON file looks like that:

  "cn": {
    "translators": ["Ran Zhuang", "Yan Jing"],
    "name": "Chinese (Simplified)",
    "local_name": "中文",
    "iso_code": "zh",
    "iso_locale": "CN",
    "iso_script": "Hans",
    "iso_version":1
    "font": {
        "family": "Lavi",
        "size": 36,
        "weight": "bold"
    },
    "title_regex": [
        {
            "pattern": "^i ([0-9]+) mo'o ",
            "replacement": "ni'o \\1 mo'o "
        }
    ]
  },

Description

"cn": {: The Pepper&Carrot lang ID. Each node of the json file starts with the two letter that identify the language across the Pepper&Carrot project. It's limited to two characters (so far, two lowercase letters) and you'll find this identifier on the URL of the website, as a directory name for the SVGs in the langs subdirectory of each episode and as a prefix for all rendered JPGs and PNGs files on the server. This identifier is not compliant with any ISO standard but tries to inspire itself from the ISO 639-1 two letters whenever it is possible.

"translators": ["Ran Zhuang", "Yan Jing"],: The attribution. This line contains the name or nickname for each translators who participated on the translation. You can add names adding comas this way "translators": ["Translator Name A", "Translator Name B", "Translator Name C"], Limitation: Don't embed HTML tag in this string and if you want to use quotes to write a nickname in the string, you'll need to escape it by placing a backlash in front of it (eg. "David \"Deevad\" Revoy").

Right now this system is designed to allow external application to correctly attribute translators but this system cannot really transmit an idea of the quantification of work done by a contributor over another one. Unfortunately, a corrector of a single episode will get their name at the same level of the main translator of the language. To write more data, including adding URL, contact information, and more background on who did what on the translation of each episode, please write it to the info.json file in the translation folder.

"name": "Chinese (Simplified)",: The English way to name this language. This line is obvious, if you have no idea, search for the language page on Wikipedia and switch the language selection of the page to English, or look for it in the Common Locale Data Repository.

"local_name": "中文",: The local way (in the language) to name this language. This line is obvious too. Here again a search for the language on Wikipedia or the the Common Locale Data Repository will give you information about the official name of the language. Note: This text will be reused for the language selector buttons on the top of pages of Pepper&Carrot website.

"iso_code": "zh",: The the ISO 639 language code. Write in this data socket only official ISO 639 code. It can be ISO 639-1 (preferred), ISO 639-2 or the three letters ISO 639-3. If your language doesn't have any ISO code, leave the socket empty. (eg. "iso_code": "",).

"iso_locale": "CN",: The (optional) ISO 3166-1 geographical code. First, this line is optional: you can remove it if not applicable to your language. This two letters uppercase helps to specify a country, dependent territory, or a special area of geographical interest. Here again a search on the dedicated Wikipedia ISO 3166-1 table will help you to find the appropriate code.

"iso_script": "Hans",: The (optional) ISO 15924 script code. Only use this if your languages could be written in more than one script, e.g. Chinese (Traditional) vs. Chinese (Simplified), of Serbian (Cyrillic) vs. Serbian (Latin). You can check the Wikipedia page or the Common Locale Data Repository's page for the correct code.

"iso_version":1: The version of the ISO 639 standard. This socket of data support only 4 choices: -1, 1, 2 and 3.

  • -1 means the language never was registered in ISO 639-1, ISO 639-2 or ISO 639-3. (eg. Language less commonly spoken as Gallo language or non registered constructed language). Writing here -1 is mandatory if you left previously the ISO code empty (eg. "iso_code": "",).
  • 1: The two lowercase letter of the ISO 639-1.
  • 2: The two lowercase letter of the ISO 639-2.
  • 3: The three lowercase letter of the ISO 639-3.

"font": The font used for rendering the thumbnails in the webcomic page and its size. Usually this is filled and fine-tuned by David Revoy accordingly to the font you used on translating the title of Pepper&Carrot pages. This information helps the renderfarm to auto-generate the episode thumbnails. If you have imagemagick installed, you can obtain a list of available fonts in your system by running convert -list font > fonts.txt in a terminal. The weight parameter is optional and defaults to normal. For a list of legal weight values see The Pango Markup Language.

"title_regex": OPTIONAL: Regular expression for transforming title text. Most languages won't need this parameter at all. Use it only if your thumbnail episode titles need to differ from the titles on the comic pages. We introduced this parameter to transform "i 1 mo'o..." to "ni'o 1 mo'o..." etc. for the Lojban language. If you need rules like this for your language, open an issue and we'll work it out together.