diff options
author | ArthurHoaro <arthur@hoa.ro> | 2017-08-19 10:53:19 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2017-10-22 13:16:56 +0200 |
commit | 6a65bc579810e3688a63a7c3b0e720dc0f5456b0 (patch) | |
tree | b1c76298c1278f351eabe47489b7ebff97efd8f2 | |
parent | f39580c6fd171b849cec5832b4912182696341f2 (diff) | |
download | Shaarli-6a65bc579810e3688a63a7c3b0e720dc0f5456b0.tar.gz Shaarli-6a65bc579810e3688a63a7c3b0e720dc0f5456b0.tar.zst Shaarli-6a65bc579810e3688a63a7c3b0e720dc0f5456b0.zip |
Translations : Working demo example of translation extension
-rw-r--r-- | application/Utils.php | 2 | ||||
-rw-r--r-- | inc/languages/fr/LC_MESSAGES/shaarli.po | 70 | ||||
-rw-r--r-- | plugins/demo_plugin/demo_plugin.php | 28 | ||||
-rw-r--r-- | plugins/demo_plugin/languages/fr/LC_MESSAGES/demo.mo | bin | 0 -> 652 bytes | |||
-rw-r--r-- | plugins/demo_plugin/languages/fr/LC_MESSAGES/demo.po | 21 |
5 files changed, 86 insertions, 35 deletions
diff --git a/application/Utils.php b/application/Utils.php index 27eaafc5..2f38a8de 100644 --- a/application/Utils.php +++ b/application/Utils.php | |||
@@ -480,7 +480,7 @@ function alphabetical_sort(&$data, $reverse = false, $byKeys = false) | |||
480 | * @param int $nb The number of items for plural forms. | 480 | * @param int $nb The number of items for plural forms. |
481 | * @param string $domain The domain where the translation is stored (default: shaarli). | 481 | * @param string $domain The domain where the translation is stored (default: shaarli). |
482 | * | 482 | * |
483 | * @return String Text translated. | 483 | * @return string Text translated. |
484 | */ | 484 | */ |
485 | function t($text, $nText = '', $nb = 1, $domain = 'shaarli') { | 485 | function t($text, $nText = '', $nb = 1, $domain = 'shaarli') { |
486 | return dn__($domain, $text, $nText, $nb); | 486 | return dn__($domain, $text, $nText, $nb); |
diff --git a/inc/languages/fr/LC_MESSAGES/shaarli.po b/inc/languages/fr/LC_MESSAGES/shaarli.po index cb9161db..6b2de950 100644 --- a/inc/languages/fr/LC_MESSAGES/shaarli.po +++ b/inc/languages/fr/LC_MESSAGES/shaarli.po | |||
@@ -1,15 +1,15 @@ | |||
1 | msgid "" | 1 | msgid "" |
2 | msgstr "" | 2 | msgstr "" |
3 | "Project-Id-Version: Shaarli\n" | 3 | "Project-Id-Version: Shaarli\n" |
4 | "POT-Creation-Date: 2017-09-01 19:21+0200\n" | 4 | "POT-Creation-Date: 2017-10-22 13:13+0200\n" |
5 | "PO-Revision-Date: 2017-09-01 19:21+0200\n" | 5 | "PO-Revision-Date: 2017-10-22 13:14+0200\n" |
6 | "Last-Translator: \n" | 6 | "Last-Translator: \n" |
7 | "Language-Team: Shaarli\n" | 7 | "Language-Team: Shaarli\n" |
8 | "Language: fr_FR\n" | 8 | "Language: fr_FR\n" |
9 | "MIME-Version: 1.0\n" | 9 | "MIME-Version: 1.0\n" |
10 | "Content-Type: text/plain; charset=UTF-8\n" | 10 | "Content-Type: text/plain; charset=UTF-8\n" |
11 | "Content-Transfer-Encoding: 8bit\n" | 11 | "Content-Transfer-Encoding: 8bit\n" |
12 | "X-Generator: Poedit 2.0.3\n" | 12 | "X-Generator: Poedit 2.0.4\n" |
13 | "X-Poedit-Basepath: ../../../..\n" | 13 | "X-Poedit-Basepath: ../../../..\n" |
14 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" | 14 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" |
15 | "X-Poedit-SourceCharset: UTF-8\n" | 15 | "X-Poedit-SourceCharset: UTF-8\n" |
@@ -27,19 +27,19 @@ msgstr "" | |||
27 | "peut donc pas fonctionner. Votre version de PHP a des failles de sécurités " | 27 | "peut donc pas fonctionner. Votre version de PHP a des failles de sécurités " |
28 | "connues et devrait être mise à jour au plus tôt." | 28 | "connues et devrait être mise à jour au plus tôt." |
29 | 29 | ||
30 | #: application/ApplicationUtils.php:182 application/ApplicationUtils.php:194 | 30 | #: application/ApplicationUtils.php:183 application/ApplicationUtils.php:195 |
31 | msgid "directory is not readable" | 31 | msgid "directory is not readable" |
32 | msgstr "le répertoire n'est pas accessible en lecture" | 32 | msgstr "le répertoire n'est pas accessible en lecture" |
33 | 33 | ||
34 | #: application/ApplicationUtils.php:197 | 34 | #: application/ApplicationUtils.php:198 |
35 | msgid "directory is not writable" | 35 | msgid "directory is not writable" |
36 | msgstr "le répertoire n'est pas accessible en écriture" | 36 | msgstr "le répertoire n'est pas accessible en écriture" |
37 | 37 | ||
38 | #: application/ApplicationUtils.php:215 | 38 | #: application/ApplicationUtils.php:216 |
39 | msgid "file is not readable" | 39 | msgid "file is not readable" |
40 | msgstr "le fichier n'est pas accessible en lecture" | 40 | msgstr "le fichier n'est pas accessible en lecture" |
41 | 41 | ||
42 | #: application/ApplicationUtils.php:218 | 42 | #: application/ApplicationUtils.php:219 |
43 | msgid "file is not writable" | 43 | msgid "file is not writable" |
44 | msgstr "le fichier n'est pas accessible en écriture" | 44 | msgstr "le fichier n'est pas accessible en écriture" |
45 | 45 | ||
@@ -58,11 +58,11 @@ msgstr "Liens directs" | |||
58 | msgid "Permalink" | 58 | msgid "Permalink" |
59 | msgstr "Permalien" | 59 | msgstr "Permalien" |
60 | 60 | ||
61 | #: application/History.php:158 | 61 | #: application/History.php:174 |
62 | msgid "History file isn't readable or writable" | 62 | msgid "History file isn't readable or writable" |
63 | msgstr "Le fichier d'historique n'est pas accessible en lecture ou en écriture" | 63 | msgstr "Le fichier d'historique n'est pas accessible en lecture ou en écriture" |
64 | 64 | ||
65 | #: application/History.php:169 | 65 | #: application/History.php:185 |
66 | msgid "Could not parse history file" | 66 | msgid "Could not parse history file" |
67 | msgstr "Format incorrect pour le fichier d'historique" | 67 | msgstr "Format incorrect pour le fichier d'historique" |
68 | 68 | ||
@@ -135,7 +135,7 @@ msgstr "" | |||
135 | "Pssst ! Je suis un lien privé que VOUS êtes le seul à voir. Vous pouvez me " | 135 | "Pssst ! Je suis un lien privé que VOUS êtes le seul à voir. Vous pouvez me " |
136 | "supprimer aussi." | 136 | "supprimer aussi." |
137 | 137 | ||
138 | #: application/LinkFilter.php:415 | 138 | #: application/LinkFilter.php:452 |
139 | msgid "The link you are trying to reach does not exist or has been deleted." | 139 | msgid "The link you are trying to reach does not exist or has been deleted." |
140 | msgstr "Le lien que vous essayez de consulter n'existe pas ou a été supprimé." | 140 | msgstr "Le lien que vous essayez de consulter n'existe pas ou a été supprimé." |
141 | 141 | ||
@@ -143,29 +143,29 @@ msgstr "Le lien que vous essayez de consulter n'existe pas ou a été supprimé. | |||
143 | msgid "Invalid export selection:" | 143 | msgid "Invalid export selection:" |
144 | msgstr "Sélection d'export invalide :" | 144 | msgstr "Sélection d'export invalide :" |
145 | 145 | ||
146 | #: application/NetscapeBookmarkUtils.php:80 | 146 | #: application/NetscapeBookmarkUtils.php:81 |
147 | #, php-format | 147 | #, php-format |
148 | msgid "File %s (%d bytes) " | 148 | msgid "File %s (%d bytes) " |
149 | msgstr "Le fichier %s (%d octets) " | 149 | msgstr "Le fichier %s (%d octets) " |
150 | 150 | ||
151 | #: application/NetscapeBookmarkUtils.php:82 | 151 | #: application/NetscapeBookmarkUtils.php:83 |
152 | msgid "has an unknown file format. Nothing was imported." | 152 | msgid "has an unknown file format. Nothing was imported." |
153 | msgstr "a un format inconnu. Rien n'a été importé." | 153 | msgstr "a un format inconnu. Rien n'a été importé." |
154 | 154 | ||
155 | #: application/NetscapeBookmarkUtils.php:85 | 155 | #: application/NetscapeBookmarkUtils.php:86 |
156 | #, php-format | 156 | #, php-format |
157 | msgid "" | 157 | msgid "" |
158 | "was successfully processed: %d links imported, %d links overwritten, %d " | 158 | "was successfully processed in %d seconds: %d links imported, %d links " |
159 | "links skipped." | 159 | "overwritten, %d links skipped." |
160 | msgstr "" | 160 | msgstr "" |
161 | "a été importé avec succès : %d liens importés, %d liens écrasés, %d liens " | 161 | "a été importé avec succès en %d secondes : %d liens importés, %d liens " |
162 | "ignorés." | 162 | "écrasés, %d liens ignorés." |
163 | 163 | ||
164 | #: application/PageBuilder.php:160 | 164 | #: application/PageBuilder.php:165 |
165 | msgid "The page you are trying to reach does not exist or has been deleted." | 165 | msgid "The page you are trying to reach does not exist or has been deleted." |
166 | msgstr "La page que vous essayez de consulter n'existe pas ou a été supprimée." | 166 | msgstr "La page que vous essayez de consulter n'existe pas ou a été supprimée." |
167 | 167 | ||
168 | #: application/PageBuilder.php:162 | 168 | #: application/PageBuilder.php:167 |
169 | msgid "404 Not Found" | 169 | msgid "404 Not Found" |
170 | msgstr "404 Introuvable" | 170 | msgstr "404 Introuvable" |
171 | 171 | ||
@@ -249,58 +249,62 @@ msgstr "Vous n'êtes pas autorisé à modifier la configuration." | |||
249 | msgid "Error accessing" | 249 | msgid "Error accessing" |
250 | msgstr "Une erreur s'est produite en accédant à" | 250 | msgstr "Une erreur s'est produite en accédant à" |
251 | 251 | ||
252 | #: index.php:134 | 252 | #: index.php:133 |
253 | msgid "Shared links on " | 253 | msgid "Shared links on " |
254 | msgstr "Liens partagés sur " | 254 | msgstr "Liens partagés sur " |
255 | 255 | ||
256 | #: index.php:156 | 256 | #: index.php:155 |
257 | msgid "Insufficient permissions:" | 257 | msgid "Insufficient permissions:" |
258 | msgstr "Permissions insuffisantes :" | 258 | msgstr "Permissions insuffisantes :" |
259 | 259 | ||
260 | #: index.php:383 | 260 | #: index.php:382 |
261 | msgid "I said: NO. You are banned for the moment. Go away." | 261 | msgid "I said: NO. You are banned for the moment. Go away." |
262 | msgstr "NON. Vous êtes banni pour le moment. Revenez plus tard." | 262 | msgstr "NON. Vous êtes banni pour le moment. Revenez plus tard." |
263 | 263 | ||
264 | #: index.php:448 | 264 | #: index.php:447 |
265 | msgid "Wrong login/password." | 265 | msgid "Wrong login/password." |
266 | msgstr "Nom d'utilisateur ou mot de passe incorrects." | 266 | msgstr "Nom d'utilisateur ou mot de passe incorrects." |
267 | 267 | ||
268 | #: index.php:1091 | 268 | #: index.php:1107 |
269 | msgid "You are not supposed to change a password on an Open Shaarli." | 269 | msgid "You are not supposed to change a password on an Open Shaarli." |
270 | msgstr "" | 270 | msgstr "" |
271 | "Vous n'êtes pas censé modifier le mot de passe d'un Shaarli en mode ouvert." | 271 | "Vous n'êtes pas censé modifier le mot de passe d'un Shaarli en mode ouvert." |
272 | 272 | ||
273 | #: index.php:1096 index.php:1137 index.php:1213 index.php:1243 index.php:1343 | 273 | #: index.php:1112 index.php:1153 index.php:1229 index.php:1259 index.php:1359 |
274 | msgid "Wrong token." | 274 | msgid "Wrong token." |
275 | msgstr "Jeton invalide." | 275 | msgstr "Jeton invalide." |
276 | 276 | ||
277 | #: index.php:1101 | 277 | #: index.php:1117 |
278 | msgid "The old password is not correct." | 278 | msgid "The old password is not correct." |
279 | msgstr "L'ancien mot de passe est incorrect." | 279 | msgstr "L'ancien mot de passe est incorrect." |
280 | 280 | ||
281 | #: index.php:1121 | 281 | #: index.php:1137 |
282 | msgid "Your password has been changed" | 282 | msgid "Your password has been changed" |
283 | msgstr "Votre mot de passe a été modifié" | 283 | msgstr "Votre mot de passe a été modifié" |
284 | 284 | ||
285 | #: index.php:1174 | 285 | #: index.php:1190 |
286 | msgid "Configuration was saved." | 286 | msgid "Configuration was saved." |
287 | msgstr "La configuration a été sauvegardé." | 287 | msgstr "La configuration a été sauvegardé." |
288 | 288 | ||
289 | #: index.php:1225 | 289 | #: index.php:1241 |
290 | #, php-format | 290 | #, php-format |
291 | msgid "The tag was removed from %d link." | 291 | msgid "The tag was removed from %d link." |
292 | msgid_plural "The tag was removed from %d links." | 292 | msgid_plural "The tag was removed from %d links." |
293 | msgstr[0] "Le tag a été supprimé de %d lien." | 293 | msgstr[0] "Le tag a été supprimé de %d lien." |
294 | msgstr[1] "Le tag a été supprimé de %d liens." | 294 | msgstr[1] "Le tag a été supprimé de %d liens." |
295 | 295 | ||
296 | #: index.php:1226 | 296 | #: index.php:1242 |
297 | #, php-format | 297 | #, php-format |
298 | msgid "The tag was renamed in %d link." | 298 | msgid "The tag was renamed in %d link." |
299 | msgid_plural "The tag was renamed in %d links." | 299 | msgid_plural "The tag was renamed in %d links." |
300 | msgstr[0] "Le tag a été renommé dans %d lien." | 300 | msgstr[0] "Le tag a été renommé dans %d lien." |
301 | msgstr[1] "Le tag a été renommé dans %d liens." | 301 | msgstr[1] "Le tag a été renommé dans %d liens." |
302 | 302 | ||
303 | #: index.php:1551 | 303 | #: index.php:1458 |
304 | msgid "Note: " | ||
305 | msgstr "Note : " | ||
306 | |||
307 | #: index.php:1567 | ||
304 | #, php-format | 308 | #, php-format |
305 | msgid "" | 309 | msgid "" |
306 | "The file you are trying to upload is probably bigger than what this " | 310 | "The file you are trying to upload is probably bigger than what this " |
@@ -310,7 +314,7 @@ msgstr "" | |||
310 | "le serveur web peut accepter (%s). Merci de l'envoyer en parties plus " | 314 | "le serveur web peut accepter (%s). Merci de l'envoyer en parties plus " |
311 | "légères." | 315 | "légères." |
312 | 316 | ||
313 | #: index.php:1967 | 317 | #: index.php:1983 |
314 | #, php-format | 318 | #, php-format |
315 | msgid "" | 319 | msgid "" |
316 | "<pre>Sessions do not seem to work correctly on your server.<br>Make sure the " | 320 | "<pre>Sessions do not seem to work correctly on your server.<br>Make sure the " |
@@ -329,7 +333,7 @@ msgstr "" | |||
329 | "cookies. Nous vous recommandons d'accéder à votre serveur depuis son adresse " | 333 | "cookies. Nous vous recommandons d'accéder à votre serveur depuis son adresse " |
330 | "IP ou un <em>Fully Qualified Domain Name</em>.<br>" | 334 | "IP ou un <em>Fully Qualified Domain Name</em>.<br>" |
331 | 335 | ||
332 | #: index.php:1977 | 336 | #: index.php:1993 |
333 | msgid "Click to try again." | 337 | msgid "Click to try again." |
334 | msgstr "Cliquer ici pour réessayer." | 338 | msgstr "Cliquer ici pour réessayer." |
335 | 339 | ||
diff --git a/plugins/demo_plugin/demo_plugin.php b/plugins/demo_plugin/demo_plugin.php index 3a90ae6a..b80a2b6d 100644 --- a/plugins/demo_plugin/demo_plugin.php +++ b/plugins/demo_plugin/demo_plugin.php | |||
@@ -14,6 +14,26 @@ | |||
14 | * and check user status with _LOGGEDIN_. | 14 | * and check user status with _LOGGEDIN_. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | use Shaarli\Config\ConfigManager; | ||
18 | |||
19 | /** | ||
20 | * In the footer hook, there is a working example of a translation extension for Shaarli. | ||
21 | * | ||
22 | * The extension must be attached to a new translation domain (i.e. NOT 'shaarli'). | ||
23 | * Use case: any custom theme or non official plugin can use the translation system. | ||
24 | * | ||
25 | * See the documentation for more information. | ||
26 | */ | ||
27 | const EXT_TRANSLATION_DOMAIN = 'demo'; | ||
28 | |||
29 | /* | ||
30 | * This is not necessary, but it's easier if you don't want Poedit to mix up your translations. | ||
31 | */ | ||
32 | function demo_plugin_t($text, $nText = '', $nb = 1) | ||
33 | { | ||
34 | return t($text, $nText, $nb, EXT_TRANSLATION_DOMAIN); | ||
35 | } | ||
36 | |||
17 | /** | 37 | /** |
18 | * Initialization function. | 38 | * Initialization function. |
19 | * It will be called when the plugin is loaded. | 39 | * It will be called when the plugin is loaded. |
@@ -27,6 +47,12 @@ function demo_plugin_init($conf) | |||
27 | { | 47 | { |
28 | $conf->get('toto', 'nope'); | 48 | $conf->get('toto', 'nope'); |
29 | 49 | ||
50 | if (! $conf->exists('translation.extensions.demo')) { | ||
51 | // Custom translation with the domain 'demo' | ||
52 | $conf->set('translation.extensions.demo', 'plugins/demo_plugin/languages/'); | ||
53 | $conf->write(true); | ||
54 | } | ||
55 | |||
30 | $errors[] = 'This a demo init error.'; | 56 | $errors[] = 'This a demo init error.'; |
31 | return $errors; | 57 | return $errors; |
32 | } | 58 | } |
@@ -160,7 +186,7 @@ function hook_demo_plugin_render_includes($data) | |||
160 | function hook_demo_plugin_render_footer($data) | 186 | function hook_demo_plugin_render_footer($data) |
161 | { | 187 | { |
162 | // footer text | 188 | // footer text |
163 | $data['text'][] = 'Shaarli is now enhanced by the awesome demo_plugin.'; | 189 | $data['text'][] = '<br>'. demo_plugin_t('Shaarli is now enhanced by the awesome demo_plugin.'); |
164 | 190 | ||
165 | // Free elements at the end of the page. | 191 | // Free elements at the end of the page. |
166 | $data['endofpage'][] = '<marquee id="demo_marquee">' . | 192 | $data['endofpage'][] = '<marquee id="demo_marquee">' . |
diff --git a/plugins/demo_plugin/languages/fr/LC_MESSAGES/demo.mo b/plugins/demo_plugin/languages/fr/LC_MESSAGES/demo.mo new file mode 100644 index 00000000..0f80f6ed --- /dev/null +++ b/plugins/demo_plugin/languages/fr/LC_MESSAGES/demo.mo | |||
Binary files differ | |||
diff --git a/plugins/demo_plugin/languages/fr/LC_MESSAGES/demo.po b/plugins/demo_plugin/languages/fr/LC_MESSAGES/demo.po new file mode 100644 index 00000000..921379c0 --- /dev/null +++ b/plugins/demo_plugin/languages/fr/LC_MESSAGES/demo.po | |||
@@ -0,0 +1,21 @@ | |||
1 | msgid "" | ||
2 | msgstr "" | ||
3 | "Project-Id-Version: Demo plugin\n" | ||
4 | "POT-Creation-Date: 2017-08-19 10:45+0200\n" | ||
5 | "PO-Revision-Date: 2017-08-19 11:28+0200\n" | ||
6 | "Last-Translator: \n" | ||
7 | "Language-Team: demo\n" | ||
8 | "Language: fr\n" | ||
9 | "MIME-Version: 1.0\n" | ||
10 | "Content-Type: text/plain; charset=UTF-8\n" | ||
11 | "Content-Transfer-Encoding: 8bit\n" | ||
12 | "X-Generator: Poedit 2.0.2\n" | ||
13 | "X-Poedit-Basepath: ../../..\n" | ||
14 | "Plural-Forms: nplurals=2; plural=(n > 1);\n" | ||
15 | "X-Poedit-KeywordsList: ;demo_plugin_t:1,2;demo_plugin_t\n" | ||
16 | "X-Poedit-SourceCharset: UTF-8\n" | ||
17 | "X-Poedit-SearchPath-0: .\n" | ||
18 | |||
19 | #: demo_plugin.php:173 | ||
20 | msgid "Shaarli is now enhanced by the awesome demo_plugin." | ||
21 | msgstr "Shaarli est maintenant amélioré avec le fantastique demo_plugin." | ||