Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translating Anori into your language #104

Open
OlegWock opened this issue Jul 29, 2023 · 0 comments
Open

Translating Anori into your language #104

OlegWock opened this issue Jul 29, 2023 · 0 comments

Comments

@OlegWock
Copy link
Owner

Translations to languages other than English or Ukrainian are made by community. If you would like to help updating one of existing translations (including proofreading English and Ukrainian translations) or translating Anori into completely new language you came to right place.

All translation-related files are located in src/translations. If you're good with git, you can make Pull Request with your changes (when creating PR make sure to allow me edit your PR). If you don't know what it means, you can just send your edited file right here and I'll update it in repository. Translation files follow specific format, detailed description of which you will find below.

Updating existing translations — correcting mistakes

If you found a mistake in existing translation, you can edit translation files directly (e.g. de.json for German, es.json from Spanish, etc.)

Updating existing translations — fixing untranslated strings

For translation missing strings, there is always a <lang>-missing.json file. It follows same format, but contains only untranslated strings. You need to translate them and I'll merge them back into big translation file.

If you know how to work with JavaScript projects

If you know how to work with JavaScript projects and intend on making PR, there is one extra step I would ask you to do. You'll need to run translations:merge <lang> command (lang here is language code from file name, e.g. es or zh-cn). I use yarn on this project, but npm should work to I assume (but if you use npm please don't include package-lock file in your PR). So, for yarn:

yarn install
yarn translations:merge es      # don't forget to replace language code

For npm:

npm install
npm run translations:merge es      # don't forget to replace language code

This will merge translated strings back into original file all strings for selected language.

Translating to new language

If you would like to translate Anori to new language, you need to create a new file <lang>.json and copy content of en.json there. <lang> here will be a language code from ISO 639-1, you can find list of languages and their codes here. If your want to add translation for specific region (e.g. British English or Chinese spoken in Taiwan) your language code will look like en-gb or zh-tw.

Then you just need to edit file replacing English strings with your translations (following file format).

If you know how to code in JavaScript

If you know how to work with JavaScript projects and intend on making PR, there are a few additional steps I'd ask you to do. First, you'll need to update translations/index.ts file:

  • Import your translation like this:
import deTranslation from './de.json';
  • Import moment.js locale for your language (if your translation has region, it should be lowercase: zh-cn, not zh-CN):
import 'moment/locale/de';
  • Add your language code to availableTranslations variable (region in upper case)

  • Add language name to availableTranslationsPrettyNames variable (region in upper case)

  • Add your translation you imported earlier to resources variable (region in upper case)

Then, you'll need to update webpack config to include moment locale. In webpack.config.ts file, search for localesToKeep property and add your language code (region in lower case).

And finally, update translations-manager.ts file and add your language code to FINISHED_TRANSLATIONS variable (region in lower case).

Translation file format

So translation file is basically JSON file with structure like this:

{
    "translation": {
        "noResults": "No results",
        "example": "Example",
        "weekday0": "Monday",
        "weekday1": "Tuesday",
        "settings": {
            "aboutHelp": {
                "title": "Help & about the extension",
                "p3": "Follow author on <0>Twitter</0> and <1>support Ukraine</1>."
            }
        },
        "search-plugin": {
            "name": "Internet search",
            "searchProviderForQ": "Search {{provider}} for «{{query}}»"
        },
    }
}

You need to translate only right part after :, left part is ID and it should stay same for all translation files. So, for example, here you need to translate Monday to your language, but you shouldn't change weekday0.

In some strings you might notice text like this: {{provider}}. This is placeholder, which will be replaced with actual value. You don't need to translate word inside curly brackets. However, you will need to place it in sentence where it will look natural. So if we're translating searchProviderForQ into Spanish, it should be something like Buscar {{provider}} para «{{query}}» I guess (sorry I don't speak Spanish :( ).

And there is also constructions like <0 /> and <1>some text<1/>. This is used to embed something more complex than just string (like in previous example). For example, link tag a. If there is a text between <0> and <0/> you need to translate it (in example with link it will be link's text). If it's just <0 /> you need just to move it to appropriate place in sentence (this is currently only used for shortcut hints). So if we're translating p3 into Spanish, it should be something like Sigue al autor en <0>Twitter</0> y <1>admite Ucrania</1>. I guess.

If you need to use " inside translated string, you can use it like this:

{
    "hideEditButton": "Hide \"Edit folder\" button",
}

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant