You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/services/general-info/add-translations.md
+12-4Lines changed: 12 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,13 @@ Translations have a `context` and a `translatable string`. The context is shown
29
29
* Add the `OCIS_DEFAULT_LANGUAGE` envvar in `services/<service-name>/pkg/config/config.go`.\
30
30
For details see the userlog or notifications service code.
31
31
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.
33
39
34
40
* 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:
35
41
```
@@ -46,9 +52,11 @@ Translations have a `context` and a `translatable string`. The context is shown
46
52
```
47
53
Note: o: organization, p: project, r: resource
48
54
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:
50
58
```
51
-
// context string
59
+
// this comment will appear in transifex as context
52
60
var yourString = l10n.Template("Translation String")
53
61
```
54
62
@@ -85,7 +93,7 @@ Translations have a `context` and a `translatable string`. The context is shown
0 commit comments