Skip to content

Commit c314e71

Browse files
committed
fix(docs): improve l10n docs
Signed-off-by: jkoberg <jkoberg@owncloud.com>
1 parent 7947c99 commit c314e71

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

docs/services/general-info/add-translations.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ Translations have a `context` and a `translatable string`. The context is shown
2929
* Add the `OCIS_DEFAULT_LANGUAGE` envvar in `services/<service-name>/pkg/config/config.go`.\
3030
For details see the userlog or notifications service code.
3131

32-
* Use `"github.com/owncloud/ocis/v2/ocis-pkg/l10n"` for the translation.
32+
* Add the `<SERVICE_NAME>_TRANSLATION_PATH` envvar in `services/<service-name>/pkg/config/config.go`.\
33+
For details see the userlog or notifications service code.
34+
35+
* Use `"github.com/owncloud/ocis/v2/ocis-pkg/l10n"` for the translation.\
36+
Use `l10n.Template` to define the translation string.\
37+
Use `l10n.NewTranslator` or `l10n.NewTranslatorFromCommonConfig` to get the translator.\
38+
Use `t.Get` to translate the string. See package for more advanced usage.
3339

3440
* Create a config in `services/<service-name>/pkg/service/l10n/.tx/config` with the following content. Note that it is important to stick with `ocis-<service-name>` to easily identify all ocis translations on Transifex:
3541
```
@@ -46,9 +52,11 @@ Translations have a `context` and a `translatable string`. The context is shown
4652
```
4753
Note: o: organization, p: project, r: resource
4854

49-
* Create a go file like `templates.go` in `ocis/services/<service-name>/pkg/service` that will define your translation sources like the following:
55+
* Create an empty file `services/<service-name>/pkg/service/l10n/locale/en/LC_MESSAGES/<service-name>.po`. This is required for ocis to build. This file will be replaced nightly with the latest translations from Transifex.
56+
57+
* Create a go file like `templates.go` in e.g. `ocis/services/<service-name>/pkg/service` that will define your translation sources like the following:
5058
```
51-
// context string
59+
// this comment will appear in transifex as context
5260
var yourString = l10n.Template("Translation String")
5361
```
5462

@@ -85,7 +93,7 @@ Translations have a `context` and a `translatable string`. The context is shown
8593
l10n-read: $(GO_XGETTEXT)
8694
go-xgettext -o $(OUTPUT_DIR)/<service-name>.pot \
8795
--keyword=l10n.Template --add-comments -s \
88-
ocis/services/<service-name>/pkg/service/templates.go
96+
pkg/service/templates.go
8997
9098
.PHONY: l10n-write
9199
l10n-write:

0 commit comments

Comments
 (0)