azukaar / Cosmos-Server

☁️ The Most Secure and Easy Selfhosted Home Server. Take control of your data and privacy without sacrificing security and stability (Authentication, anti-DDOS, anti-bot)
https://cosmos-cloud.io
Other
3.65k stars 130 forks source link

i18n: add support for translation to markets #281

Closed madejackson closed 3 months ago

madejackson commented 4 months ago

This PR includes translation-support for markets without breaking support for existing markets/apps without translation-fields. The PR is based on my previous PR for general Translation-Support. #273

It's basically some additional checks to the json-fields coming from markets. If there is a translation available of the specific field, it'll show the translated value. It supports staged fallback from locale (f.e. de-CH) to language (f.e. de) to default

As the official market has no translated fields as of yet, you can test it with my fork, which is translated to de and de-CH: https://github.com/aseracorp/resiSTORE

Feel free to request changes / improvements.

The PR expects the following structure for the description and cosmos-installer:

description.json

{
  "name": "name",
  "description": "englishEnglishEnglish",
  "longDescription": "englishEnglishEnglish",
  "translation": {
    "de": {
      "description": "germanGermanGerman",
      "longDescription": "germanGermanGerman"
    }
  },
 "tags": ["tags"],
  "repository": "repo",
  "image": "image",
  "supported_architectures": ["amd64", "arm64"]
}
cosmos-compose.json:
  "cosmos-installer": {
    "form": [
      {
        "name": "useping",
        "label": "Do you want to use ping instead of mDNS?",
        "initialValue": "false",
        "type": "select",
        "options": [
          ["true", "true"],
          ["false", "false"]
        ]
      },
      {
        "name": "username",
        "label": "What should be the username?",
        "initialValue": "admin",
        "type": "text"
      },
      {
        "name": "password",
        "label": "What should be the password?",
        "initialValue": "admin",
        "type": "text"
      }
    ],
    "translation": {
      "de": {
        "form.useping.label": "Möchten Sie ping anstelle von mDNS verwenden?",
        "form.useping.options": [ ["true", "Ja"],
                                  ["false", "Nein"] ],
        "form.username.label": "Wie soll der Benutzername lauten?",
        "form.password.label": "Wie sollte das Passwort lauten?"
      }
    }
  },
cla-bot[bot] commented 4 months ago

We require contributors to sign our Contributor License Agreement. In order for us to review and merge your code, add yourself to the .clabot file as contributor, as a way of signing the CLA.

madejackson commented 3 months ago

Will be reopened against unstable