91a21c2729
- 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
157 lines
5.3 KiB
Markdown
157 lines
5.3 KiB
Markdown
## Translations
|
|
|
|
Shaarli supports [gettext](https://www.gnu.org/software/gettext/manual/gettext.html) translations
|
|
since `>= v0.9.2`.
|
|
|
|
Note that only the `default` theme supports translations.
|
|
|
|
### Contributing
|
|
|
|
We encourage the community to contribute to Shaarli translations, either by improving existing translations or submitting a new language.
|
|
|
|
Contributing to the translation does not require software development knowledge.
|
|
|
|
Please 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.
|
|
|
|
|
|
### How to
|
|
|
|
Install [Poedit](https://poedit.net/) (used to extract strings to translate from the PHP source code, and generate `.po` files).
|
|
|
|
Due 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 :
|
|
|
|
```
|
|
http://<replace_domain>/
|
|
http://<replace_domain>/login
|
|
http://<replace_domain>/daily
|
|
http://<replace_domain>/tags/cloud
|
|
http://<replace_domain>/tags/list
|
|
http://<replace_domain>/picture-wall
|
|
http://<replace_domain>/?nonope
|
|
http://<replace_domain>/admin/add-shaare
|
|
http://<replace_domain>/admin/password
|
|
http://<replace_domain>/admin/tags
|
|
http://<replace_domain>/admin/configure
|
|
http://<replace_domain>/admin/tools
|
|
http://<replace_domain>/admin/shaare
|
|
http://<replace_domain>/admin/export
|
|
http://<replace_domain>/admin/import
|
|
http://<replace_domain>/admin/plugins
|
|
```
|
|
|
|
|
|
#### Improve existing translations
|
|
|
|
- In Poedit, click on "Edit a Translation
|
|
- Open `inc/languages/<lang>/LC_MESSAGES/shaarli.po` under Shaarli's directory
|
|
- The existing list of translatable strings should load
|
|
- Click on the "Update" button.
|
|
- Start editing translations.
|
|
|
|
![poedit-screenshot](images/poedit-1.jpg)
|
|
|
|
Save when you're done, then you can submit a pull request containing the updated `shaarli.po`.
|
|
|
|
|
|
#### Add a new language
|
|
|
|
- In Poedit select "Create New Translation"
|
|
- Open `inc/languages/<lang>/LC_MESSAGES/shaarli.po` under Shaarli's directory
|
|
- Select the language you want to create.
|
|
- 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)
|
|
- Click on the "Update" button
|
|
- Start editing translations.
|
|
|
|
Save when you're done, then you can submit a pull request containing the new `shaarli.po`.
|
|
|
|
|
|
### Theme translations
|
|
|
|
[Theme](Theming) translation extensions are loaded automatically if they're present.
|
|
|
|
As a theme developer, all you have to do is to add the `.po` and `.mo` compiled file like this:
|
|
|
|
```
|
|
tpl/<theme name>/language/<lang>/LC_MESSAGES/<theme name>.po
|
|
tpl/<theme name>/language/<lang>/LC_MESSAGES/<theme name>.mo
|
|
```
|
|
|
|
Where `<lang>` is the ISO 3166-1 alpha-2 language code.
|
|
|
|
Read the following section "Extend Shaarli's translation" to learn how to generate those files.
|
|
|
|
|
|
### Extend Shaarli's translation
|
|
|
|
If you're writing a custom theme, or a non official plugin, you might want to use the translation system,
|
|
but you won't be able to able to override Shaarli's translation.
|
|
|
|
However, you can add your own translation domain which extends the main translation list.
|
|
|
|
> Note that you can find a live example of translation extension in the `demo_plugin`.
|
|
|
|
First, create your translation files tree directory:
|
|
|
|
```
|
|
<your_module>/languages/<ISO 3166-1 alpha-2 language code>/LC_MESSAGES/
|
|
```
|
|
|
|
Your `.po` files must be named like your domain. E.g. if your translation domain is `my_theme`, then your file will be
|
|
`my_theme.po`.
|
|
|
|
Users have to register your extension in their configuration with the parameter
|
|
`translation.extensions.<domain>: <translation files path>`.
|
|
|
|
Example:
|
|
|
|
```php
|
|
if (! $conf->exists('translation.extensions.my_theme')) {
|
|
$conf->set('translation.extensions.my_theme', '<your_module>/languages/');
|
|
$conf->write(true);
|
|
}
|
|
```
|
|
|
|
> Note that the page needs to be reloaded after the registration.
|
|
|
|
It is then recommended to create a custom translation function which will call the `t()` function with your domain.
|
|
For example :
|
|
|
|
```php
|
|
function my_theme_t($text, $nText = '', $nb = 1)
|
|
{
|
|
return t($text, $nText, $nb, 'my_theme'); // the last parameter is your translation domain.
|
|
}
|
|
```
|
|
|
|
All strings which can be translated should be processed through your function:
|
|
|
|
```php
|
|
my_theme_t('Comment');
|
|
my_theme_t('Comment', 'Comments', 2);
|
|
```
|
|
|
|
Or in templates:
|
|
|
|
```php
|
|
{'Comment'|my_theme_t}
|
|
{function="my_theme_t('Comment', 'Comments', 2)"}
|
|
```
|
|
|
|
> Note than in template, you need to visit your page at least once to generate a cache file.
|
|
|
|
When you're done, open Poedit and load translation strings from sources:
|
|
|
|
1. `File > New`
|
|
2. Choose your language
|
|
3. Save your `PO` file in `<your_module>/languages/<language code>/LC_MESSAGES/my_theme.po`.
|
|
4. Go to `Catalog > Properties...`
|
|
5. Fill the `Translation Properties` tab
|
|
6. Add your source path in the `Sources Paths` tab
|
|
7. In the `Sources Keywords` tab uncheck "Also use default keywords" and add the following lines:
|
|
|
|
```
|
|
my_theme_t
|
|
my_theme_t:1,2
|
|
```
|
|
|
|
Click on the "Update" button and you're free to start your translations!
|