Skip to content

Commit

Permalink
Updates translations documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pedropalau committed Jul 8, 2020
1 parent 7a05edd commit 8ef10bb
Showing 1 changed file with 63 additions and 28 deletions.
91 changes: 63 additions & 28 deletions TRANSLATIONS.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,94 @@
# Translations

New translations in Wahay can be done in the following way:
To translate Wahay you will need to build it with the new translated messages.

Fork wahay under a directory with the structure:
To do that, please read the below instructions carefully and follow the steps.

```console
➀ Clone `Wahay` into a directory with the following structure:

```bash
$GOPATH/src/github.com/digitalautonomy/wahay
```

Another important thing is add **$GOPATH/bin to $PATH**
Another important thing to do is to add `$GOPATH/bin` to `$PATH`.

In this point the following commands must run without issues inside $GOPATH/src/github.com/digitalautonomy/wahay:
At this point you must run the below commands in Wahay's directory:

```console
```bash
$ cd $GOPATH/src/github.com/digitalautonomy/wahay
$ make deps
$ make default
```

To add a new language translation add the required folder under locales for example fr:
➁ Create new language folder

To add a new translation you should create the language folder under `locales` directory:

```console
src/github.com/digitalautonomy/wahay/gui/locales/fr
```bash
$ cd $GOPATH/src/github.com/digitalautonomy/wahay/gui/locales

# Create a new folder for French language
$ mkdir fr
```

After that copy one of the messages.gotext.json files of en or es folders to use as a reference. In this file also is required set the code of language to be used, for example: "language": "fr" and add all the translations in translation tag:
➂ Copy the `messages.gotext.json` file from __English__ (`en`) or __Spanish__ (`es`) folders as a reference, into the created language folder:

```bash
$ cd $GOPATH/src/github.com/digitalautonomy/wahay/gui/locales
$ cp ./en/messages.gotext.json ./fr
```

The `messages.gotext.json` must have the following structure that contains the language code and all translated messages:

```json
{
"id": "Welcome",
"message": "Welcome",
"translation": "Bienvenue"
"language": "fr",
"messages": [
{
...
},
{
"id": "Welcome",
"message": "Welcome",
"translation": "Bienvenue"
}
{
...
}
]
}
```

After that modify i18.go:
```go
//go:generate gotext -srclang=en update -out=catalog/catalog.go -lang=en,es,sv,ar
➃ Modify the `i18.go` file to run the new language source:

```bash
$ cd $GOPATH/src/github.com/digitalautonomy/wahay
$ nano gui/i18.go
```

to add the new language to be translated:
And add the language code to the list of languages

```go
//go:generate gotext -srclang=en update -out=catalog/catalog.go -lang=en,es,sv,ar,fr
//go:generate gotext -srclang=en update-out=catalog/catalog.go -lang=en,es,sv,ar,fr
```

Now its possible execute:
```console
make gen-ui-locale
Now its possible execute the command:

```bash
# cd $GOPATH/src/github.com/digitalautonomy/wahay
$ make gen-ui-locale
```
under **src/github.com/digitalautonomy/wahay**

finally
```console
make default
And finally run:

```bash
$ make default
```

To check the new language its possible use: **export LANG="fr_FR.utf8"** and run wahay:
```console
bin/wahay
➄ Check the new language:

```bash
$ export LANG="fr_FR.utf8"
$ cd $GOPATH/src/github.com/digitalautonomy/wahay
$ bin/wahay
```

0 comments on commit 8ef10bb

Please sign in to comment.