aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc/md/dev/Translations.md
diff options
context:
space:
mode:
authornodiscc <nodiscc@gmail.com>2020-05-16 12:54:51 +0200
committernodiscc <nodiscc@gmail.com>2020-09-12 14:31:45 +0200
commit91a21c272960889afd4eaa431a3d29b7785b6efc (patch)
tree26e3ba62319964c5fd48d93fdfe47813d5dc9bf5 /doc/md/dev/Translations.md
parent6128ab6a55430a2b705be31ff417c0c552a0db1f (diff)
downloadShaarli-91a21c272960889afd4eaa431a3d29b7785b6efc.tar.gz
Shaarli-91a21c272960889afd4eaa431a3d29b7785b6efc.tar.zst
Shaarli-91a21c272960889afd4eaa431a3d29b7785b6efc.zip
**General rewording, proof-reading, deduplication, shortening, reordering, simplification, cleanup/formatting/standardization**
- standardize page names, rework documentation structure, update TOC - use same example paths everywhere - level 1 titles on all pages - fix broken links - .md suffix on all page links (works both from readthedocs and github repository views) **Server:** A full and concise installation guide with examples is a frequent request. The documentation should provide such a guide for basic installation needs, while explaining alternative/advanced configuration at the end. Links to reference guides and documentation should be used more frequently to avoid recommending an outdated or excessively complex configuration. - server: move most server-related info to server-configuration.md, cleanup/shorten - server: update list of php dependencies/libraries, link to composer.json - server: installation: support 3 install methods (from release zip, from sources, using docker) - server: installation: use rsync instead of mv as mv results will change depending of taget directory already existing or not - server: add example/basic usage of certbot - server, upgrade, installation: update file permissions setup, use sudo for upgrade operations in webserver document root - server: apache: add comments to configuration, fix and factorize file permissions setup, set cache-control header, deny access to dotfiles, add missing apache config steps, add http->https redirect example - server: nginx: refactor nginx configuration, add comments, DO log access to denied/protected files - server: add links to MDN for x-forwarded-* http headers explanation, cleanup/clarify robots.txt and crawlers section - server: bump file upload size limit to 100MB we have reports of bookmark exports weighing +40MB - i have a 13MB one here - server: simplify phpinfo documentation - server: move backup and restore information to dedicated page - docker: move all docker docs to Docker.md, simplify/ docker setup, add docker-compose.yml example, replace docker-101 with docker cheatsheet - troubleshooting: move all troubleshooting documentation to troubleshooting.md **Usage:** - index: add getting started section on index page - features/usage: move all usage-related documentation to usage.md, add links from the main feature list to corresponding usage docs, clarify/reword features list - shaarli configuration: add note about configuring from web interface **Removed:** - remove obsolete/orphan images - remove obsolete shaarchiver example - remove outdated "decode datastore content" snippet **Development:** - development: move development-related docs (static analysis, CI, unit tests, 3rd party libs, link structure/directory, guidelines, security....) to dev/ directory - development: Merge several pages to development.md - **Breaking change?:** remove mentions of 'stable' branch, switch to new branch/release model (master=latest commit, release=latest tag) - **Breaking change?:** refer to base sharing unit as "Shaare" everywhere (TODO: reflect changes in the code?) doc: update featues list/link to usage.md for details - development: directory structure: add note about required file permissions - .travis-ci.yml: add comments - .htaccess: add comment
Diffstat (limited to 'doc/md/dev/Translations.md')
-rw-r--r--doc/md/dev/Translations.md157
1 files changed, 157 insertions, 0 deletions
diff --git a/doc/md/dev/Translations.md b/doc/md/dev/Translations.md
new file mode 100644
index 00000000..8f3b8f10
--- /dev/null
+++ b/doc/md/dev/Translations.md
@@ -0,0 +1,157 @@
1## Translations
2
3Shaarli supports [gettext](https://www.gnu.org/software/gettext/manual/gettext.html) translations
4since `>= v0.9.2`.
5
6Note that only the `default` theme supports translations.
7
8### Contributing
9
10We encourage the community to contribute to Shaarli translations, either by improving existing translations or submitting a new language.
11
12Contributing to the translation does not require software development knowledge.
13
14Please submit a pull request with the `.po` file updated/created. Note that the compiled file (`.mo`) is not stored on the repository, and is generated during the release process.
15
16
17### How to
18
19Install [Poedit](https://poedit.net/) (used to extract strings to translate from the PHP source code, and generate `.po` files).
20
21Due to the usage of a template engine, it's important to generate PHP cache files to extract every translatable string. You can either use [this script](https://gist.github.com/ArthurHoaro/5d0323f758ab2401ef444a53f54e9a07) (recommended) or visit every template page in your browser to generate cache files, while logged in. Here is a list :
22
23```
24http://<replace_domain>/
25http://<replace_domain>/login
26http://<replace_domain>/daily
27http://<replace_domain>/tags/cloud
28http://<replace_domain>/tags/list
29http://<replace_domain>/picture-wall
30http://<replace_domain>/?nonope
31http://<replace_domain>/admin/add-shaare
32http://<replace_domain>/admin/password
33http://<replace_domain>/admin/tags
34http://<replace_domain>/admin/configure
35http://<replace_domain>/admin/tools
36http://<replace_domain>/admin/shaare
37http://<replace_domain>/admin/export
38http://<replace_domain>/admin/import
39http://<replace_domain>/admin/plugins
40```
41
42
43#### Improve existing translations
44
45- In Poedit, click on "Edit a Translation
46- Open `inc/languages/<lang>/LC_MESSAGES/shaarli.po` under Shaarli's directory
47- The existing list of translatable strings should load
48- Click on the "Update" button.
49- Start editing translations.
50
51![poedit-screenshot](images/poedit-1.jpg)
52
53Save when you're done, then you can submit a pull request containing the updated `shaarli.po`.
54
55
56#### Add a new language
57
58- In Poedit select "Create New Translation"
59- Open `inc/languages/<lang>/LC_MESSAGES/shaarli.po` under Shaarli's directory
60- Select the language you want to create.
61- Click on `File > Save as...`, save your file in `<shaarli directory>/inc/language/<new language>/LC_MESSAGES/shaarli.po` (`<new language>` here should be the language code respecting the [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-2) format in lowercase - e.g. `de` for German)
62- Click on the "Update" button
63- Start editing translations.
64
65Save when you're done, then you can submit a pull request containing the new `shaarli.po`.
66
67
68### Theme translations
69
70[Theme](Theming) translation extensions are loaded automatically if they're present.
71
72As a theme developer, all you have to do is to add the `.po` and `.mo` compiled file like this:
73
74```
75tpl/<theme name>/language/<lang>/LC_MESSAGES/<theme name>.po
76tpl/<theme name>/language/<lang>/LC_MESSAGES/<theme name>.mo
77```
78
79Where `<lang>` is the ISO 3166-1 alpha-2 language code.
80
81Read the following section "Extend Shaarli's translation" to learn how to generate those files.
82
83
84### Extend Shaarli's translation
85
86If you're writing a custom theme, or a non official plugin, you might want to use the translation system,
87but you won't be able to able to override Shaarli's translation.
88
89However, you can add your own translation domain which extends the main translation list.
90
91> Note that you can find a live example of translation extension in the `demo_plugin`.
92
93First, create your translation files tree directory:
94
95```
96<your_module>/languages/<ISO 3166-1 alpha-2 language code>/LC_MESSAGES/
97```
98
99Your `.po` files must be named like your domain. E.g. if your translation domain is `my_theme`, then your file will be
100`my_theme.po`.
101
102Users have to register your extension in their configuration with the parameter
103`translation.extensions.<domain>: <translation files path>`.
104
105Example:
106
107```php
108if (! $conf->exists('translation.extensions.my_theme')) {
109 $conf->set('translation.extensions.my_theme', '<your_module>/languages/');
110 $conf->write(true);
111}
112```
113
114> Note that the page needs to be reloaded after the registration.
115
116It is then recommended to create a custom translation function which will call the `t()` function with your domain.
117For example :
118
119```php
120function my_theme_t($text, $nText = '', $nb = 1)
121{
122 return t($text, $nText, $nb, 'my_theme'); // the last parameter is your translation domain.
123}
124```
125
126All strings which can be translated should be processed through your function:
127
128```php
129my_theme_t('Comment');
130my_theme_t('Comment', 'Comments', 2);
131```
132
133Or in templates:
134
135```php
136{'Comment'|my_theme_t}
137{function="my_theme_t('Comment', 'Comments', 2)"}
138```
139
140> Note than in template, you need to visit your page at least once to generate a cache file.
141
142When you're done, open Poedit and load translation strings from sources:
143
144 1. `File > New`
145 2. Choose your language
146 3. Save your `PO` file in `<your_module>/languages/<language code>/LC_MESSAGES/my_theme.po`.
147 4. Go to `Catalog > Properties...`
148 5. Fill the `Translation Properties` tab
149 6. Add your source path in the `Sources Paths` tab
150 7. In the `Sources Keywords` tab uncheck "Also use default keywords" and add the following lines:
151
152```
153my_theme_t
154my_theme_t:1,2
155```
156
157Click on the "Update" button and you're free to start your translations!