190 lines
7.7 KiB
Markdown
190 lines
7.7 KiB
Markdown
# Localizing Ghostty: The Translators' Guide
|
|
|
|
First of all, thanks for helping us localize Ghostty!
|
|
|
|
To begin contributing, please make sure that you have installed `gettext`
|
|
on your system, which should be available under the `gettext` package
|
|
for most Linux and macOS package managers.
|
|
|
|
You can install `gettext` on Windows in a few ways:
|
|
|
|
- Through [an installer](https://mlocati.github.io/articles/gettext-iconv-windows.html);
|
|
- Through package managers like Scoop (`scoop install gettext`) and
|
|
WinGet (`winget install gettext`) which repackages the aforementioned installer;
|
|
- Through Unix-like environments like [Cygwin](https://cygwin.com/cygwin/packages/summary/gettext.html)
|
|
and [MSYS2](https://packages.msys2.org/base/gettext).
|
|
|
|
> [!WARNING]
|
|
>
|
|
> Unlike what some tutorials suggest, **we do not recommend installing `gettext`
|
|
> through GnuWin32**, since it hasn't been updated since 2010 and very likely
|
|
> does not work on modern Windows versions.
|
|
|
|
You can verify that `gettext` has been successfully installed by running the
|
|
command `gettext -V`. If everything went correctly, you should see an output like this:
|
|
|
|
```console
|
|
$ gettext -V
|
|
gettext (GNU gettext-runtime) 0.21.1
|
|
Copyright (C) 1995-2022 Free Software Foundation, Inc.
|
|
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
|
|
This is free software: you are free to change and redistribute it.
|
|
There is NO WARRANTY, to the extent permitted by law.
|
|
Written by Ulrich Drepper.
|
|
```
|
|
|
|
With this, you're ready to localize!
|
|
|
|
## Locale names
|
|
|
|
A locale name will always consist of a [two letter language
|
|
code](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) (i.e.
|
|
`de`, `es`, `fr`). Sometimes, for languages that have regional variations
|
|
(such as `zh` and `es`), the locale name will include a [two letter
|
|
country code](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes).
|
|
One example is `es_AR` for Spanish as spoken in Argentina.
|
|
|
|
Full locale names are more complicated, but Ghostty does not use all parts. [The
|
|
`gettext` documentation](https://www.gnu.org/software/gettext/manual/gettext.html#Locale-Names-1)
|
|
has more information on locale names.
|
|
|
|
## Localization team name
|
|
|
|
Every locale will have a localization team that helps keep localizations up to
|
|
date. Localization team names _always_ consist of a language code and a country
|
|
code (e.g. `de_DE` or `zh_CN`).
|
|
|
|
## Translation file names
|
|
|
|
All translation files lie in the `po/` directory, including the main _template_
|
|
file called `com.mitchellh.ghostty.pot`. **Do not edit this file.** The
|
|
template is generated automatically from Ghostty's code and resources, and is
|
|
intended to be regenerated by code contributors. If there is a problem with
|
|
the template file, please reach out to a code contributor.
|
|
|
|
Translation file names consist of the locale name and the extension
|
|
`.po`. For example: `de.po`, `zh_CN.po`.
|
|
|
|
## Editing translation files
|
|
|
|
> [!NOTE]
|
|
>
|
|
> If the translation file for your locale does not yet exist, see the
|
|
> ["Creating new translation files" section](#creating-new-translation-files)
|
|
> of this document on how to create one.
|
|
|
|
The translation file contains a list of entries that look like this:
|
|
|
|
```po
|
|
#. Translators: the category in the right-click context menu that contains split items for all directions
|
|
#: src/apprt/gtk/ui/1.0/menu-surface-context-menu.blp:38
|
|
# 译注:其他终端程序对 Split 皆有不同翻译,此处采取最直观的翻译方式
|
|
msgctxt "Context menu"
|
|
msgid "Split"
|
|
msgstr "分屏"
|
|
```
|
|
|
|
The `msgid` line contains the original string in English, and the `msgstr` line
|
|
should contain the translation for your language. Occasionally there will also
|
|
be a `msgctxt` line that differentiates strings that are identical in English,
|
|
based on its context.
|
|
|
|
Lines beginning with `#` are comments, of which there are several kinds:
|
|
|
|
- Pay attention to comments beginning with `#.`. They are comments left
|
|
by _developers_ providing more context to the string.
|
|
|
|
- Comments that begin with `#:` are _source comments_: they link
|
|
the string to source code or resource files. You normally don't need to
|
|
consider these in your translations.
|
|
|
|
- You may also leave comments of your own to be read by _other translators_,
|
|
beginning with `# `. These comments are specific to your locale and don't
|
|
affect translators in other locales.
|
|
|
|
The first entry of the `.po` file has an empty `msgid`. This entry is special
|
|
as it stores the metadata related to the `.po` file itself. You usually do
|
|
not need to modify it.
|
|
|
|
## Creating new translation files
|
|
|
|
You can use the `msginit` tool to create new translation files.
|
|
|
|
Run the command below, replacing `X` with your [locale name](#locale-names).
|
|
|
|
```console
|
|
$ msginit -i po/com.mitchellh.ghostty.pot -l X -o "po/X.po"
|
|
```
|
|
|
|
`msginit` may prompt you for other information such as your email address,
|
|
which should be filled in accordingly. You can then add your translations
|
|
within the newly created translation file.
|
|
|
|
Afterwards, you need to update the list of known locales within Ghostty's
|
|
build system. To do so, open `src/os/i18n_locales.zig` and find the list of
|
|
locale names after the comments, then add your locale name into the list.
|
|
|
|
The order matters, so make sure to place your locale name in the correct
|
|
position. Read the comments present in the file for more details on the order.
|
|
If you're unsure, place it at the end of the list.
|
|
|
|
```zig
|
|
const locales = [_][]const u8{
|
|
"zh_CN",
|
|
// <- Add your locale name here (probably)
|
|
}
|
|
```
|
|
|
|
You should then be able to run `zig build run` and see your translations in action!
|
|
|
|
Before opening a pull request with the new translation file, you should also
|
|
add your translation file to the `CODEOWNERS` file. Find the `# Localization`
|
|
section near the bottom and add a line like so (where `X.po` is the name of the
|
|
translation file that you created and `Y` is your [localization team name](#localization-team-name):
|
|
|
|
```diff
|
|
# Localization
|
|
/po/README_TRANSLATORS.md @ghostty-org/localization
|
|
/po/com.mitchellh.ghostty.pot @ghostty-org/localization
|
|
/po/zh_CN.po @ghostty-org/zh_CN
|
|
+/po/X.po @ghostty-org/Y
|
|
```
|
|
|
|
## Style Guide
|
|
|
|
These are general style guidelines for translations. Naturally, the specific
|
|
recommended standards will differ based on the specific language/locale,
|
|
but these should serve as a baseline for the tone and voice of any translation.
|
|
|
|
- **Prefer an instructive, yet professional tone.**
|
|
|
|
In languages that exhibit distinctions based on formality,
|
|
prefer the formality that is expected of instructive material on the internet.
|
|
The user should be considered an equal peer of the program and the translator,
|
|
not an esteemed customer.
|
|
|
|
- **Use simple to understand language and avoid jargon.**
|
|
|
|
Explain concepts that may be familiar in an English-speaking context,
|
|
but are uncommon in your language.
|
|
|
|
- **Do not overly literally translate foreign concepts to your language.**
|
|
|
|
Care should be taken so that your translations make sense to a reader without
|
|
any background knowledge of the English source text. To _localize_ is to
|
|
transfer a concept between languages, not to translate each word at face value.
|
|
|
|
- **Be consistent with stylistic and tonal choices.**
|
|
|
|
Consult the translations made by previous translators, and try to emulate them.
|
|
Do not overwrite someone else's hard work without substantial justification.
|
|
|
|
- **Make Ghostty fit in with surrounding applications.**
|
|
|
|
Follow existing translations for terms and concepts if possible, even when
|
|
they are suboptimal. Follow the writing styles prescribed by the human
|
|
interface guidelines of each platform Ghostty is available for, including the
|
|
[GNOME Human Interface Guidelines](https://developer.gnome.org/hig/guidelines/writing-style.html)
|
|
on Linux, and [Apple's Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines/writing)
|
|
on macOS.
|