-
Notifications
You must be signed in to change notification settings - Fork 278
Translate
Note: This page is all about how to create translations for YoutubeDL-Material. If you are simply trying to set your language within the app, you can find that option in the settings menu.
We now do community-sourced translations through Weblate! You can easily add translations at this link.
Translating YoutubeDL-Material into a new language is a multi-step process. It begins with the messages.en.xlf
file, which contains virtually all strings, (referred to as source string) within the UI in English. This is usually called a source file, and is of type XLIFF.
The target file contains both the source string and the target string, which is the translated string in the target language. Here is an excerpt from messages.es.xlf
file (view here), which is the English->Spanish translation of YoutubeDL-Material:
<trans-unit id="cff1428d10d59d14e45edec3c735a27b5482db59">
<source>Name</source>
<target>Nombre</target>
</trans-unit>
The source string and target string are clearly visible within the trans-unit
object.
The front end uses the id
in trans-unit
to connect the original string in the app with the translated string.
Translating each string manually would take a while, so you can use Computer-Assisted Translation to help you out with that like OmegaT or the web-based (with a solid free version) SmartCat.
Ultimately, the resulting translation file must be converted to JSON for consumption by the UI (messages.es.xlf
would become messages.es.json
). The reason for this is that JSON files are far smaller than XLIFFs (about 1/5 the size), and are easier to read for JavaScript-based applications.
Here is that example string shown above, this time in the messages.es.json
file (view here):
"cff1428d10d59d14e45edec3c735a27b5482db59": "Nombre",
See? A much smaller footprint! But, you may ask, isn't it incredibly tedious that I now have to convert my target XLIFF to a JSON? I felt the same way, so I created a program that takes care of that called xliff-to-json. It simply takes 1 command to generate your desired JSON containing your translated strings.
Make sure you read through the Introduction above to get yourself familiarized with the process. This section assumes you have gone through that, and are now looking to create a new translation for YoutubeDL-Material. If that's the case, awesome! Read through the following steps.
- Download the latest source XLIFF file in the
src/assets/i18n
folder in the repository. - Use your favorite CAT (computer-assisted translation) tool to translate the
messages.en.xlf
file into a targetmessages.{CODE}.xlf
file, where{CODE}
is the target language's ISO 639-1 Code. For example, English isen
and Spanish ises
. - Use xliff-to-json to convert the
messages.{CODE}.xlf
tomessages.{CODE}.json
, which is the correct format for consumption by the UI. Verify that the resulting JSON has the correct format. - If everything is looking A-OK, the next step is to submit a PR that contains your new translation. This PR should take care of 3 things:
- Add the new target XLIFF file to the
src/assets/i18n
folder. - Add the new target JSON file to the
src/assets/i18n
folder. - Add the new language code to the
supported_locales
array in thesettings.component.ts
file here
The last requirement for the PR (adding the new language code) is the least important one, so if you simply add the target xliff
and json
files, I can handle the rest.
And that's pretty much it! Once your PR is merged, then the translations should be available in the next update. If you're having trouble with any of these steps, create an issue and I'll be happy to help.
It's a way to have translations on word or phrases that can change. To translate all the possibilities, you can follow this example done in Spanish:
This
{VAR_SELECT, select, true {Close} false {Cancel} other {other} }
becomes
{VAR_SELECT, select, true {Cerrar} false {Cancelar} other {Otro} }
Basically just put the translation in the curly braces, for example Close
in Spanish is Cerrar
.