Skip to content
Fabian Homborg edited this page May 23, 2021 · 3 revisions

Fish uses the GNU gettext library to implement translation to multiple languages. If fish is not available in your language, please consider making a translation. Currently, only the shell itself can be translated; a future version of fish should also include translated manuals.

To make a translation of fish, you will first need the source code.

Download the latest version from the fish website, and unpack it by using a command like tar xvzf fish-VERSION.tar.gz. Change directory into the newly created fish directory using cd fish-VERSION.

Alternatively, if you are comfortable using the git version control system, you can clone the Git repository from git://github.com/fish-shell/fish-shell.git. Change directory into the repository with cd fish-shell.

Before you continue, you will need to know the two-letter ISO 639-1 language code of the language you are translating to. These codes can be found in the list of Codes for the Representation of Names of Languages. For example, the language code for Uighur is ug.

Let's start translating!

First, create the translation template by running build_tools/fish_xgettext.fish. This will output a file messages.pot. Copy this file to po/[LANGUAGE CODE].po if it does not exist (for example, if you are translating to Uighur, you should type cp messages.pot po/ug.po). Alternatively, to update an existing translation, use msgmerge (for example, for updating existing Uighur translations, use msgmerge --update --no-fuzzy-matching po/ug.po messages.pot).

Open the newly created .po file in your editor of choice, and start translating. The .po file format is simple. It contains pairs of string in a format like:

msgid "%ls: No suitable job\n"
msgstr ""

The first line (msgid) is the English string to translate. The second line (msgstr) should contain your translation. For example, in Swedish, the above might become:

msgid "%ls: No suitable job\n"
msgstr "%ls: Inget passande jobb\n"

%s, %ls, %d and other tokens beginning with % are placeholders. These will be replaced by a value by fish at runtime. You must always take care to use exactly the same placeholders in the same order in your translation. (There are ways to avoid this, but they are too complicated for this short introduction. See the full manual for the printf C function for more information.)

Once you have provided a translation for fish, please submit a pull request.