aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2017-08-19 10:53:19 +0200
committerArthurHoaro <arthur@hoa.ro>2017-10-22 13:16:56 +0200
commit6a65bc579810e3688a63a7c3b0e720dc0f5456b0 (patch)
treeb1c76298c1278f351eabe47489b7ebff97efd8f2
parentf39580c6fd171b849cec5832b4912182696341f2 (diff)
downloadShaarli-6a65bc579810e3688a63a7c3b0e720dc0f5456b0.tar.gz
Shaarli-6a65bc579810e3688a63a7c3b0e720dc0f5456b0.tar.zst
Shaarli-6a65bc579810e3688a63a7c3b0e720dc0f5456b0.zip
Translations : Working demo example of translation extension
-rw-r--r--application/Utils.php2
-rw-r--r--inc/languages/fr/LC_MESSAGES/shaarli.po70
-rw-r--r--plugins/demo_plugin/demo_plugin.php28
-rw-r--r--plugins/demo_plugin/languages/fr/LC_MESSAGES/demo.mobin0 -> 652 bytes
-rw-r--r--plugins/demo_plugin/languages/fr/LC_MESSAGES/demo.po21
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 */
485function t($text, $nText = '', $nb = 1, $domain = 'shaarli') { 485function 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 @@
1msgid "" 1msgid ""
2msgstr "" 2msgstr ""
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
31msgid "directory is not readable" 31msgid "directory is not readable"
32msgstr "le répertoire n'est pas accessible en lecture" 32msgstr "le répertoire n'est pas accessible en lecture"
33 33
34#: application/ApplicationUtils.php:197 34#: application/ApplicationUtils.php:198
35msgid "directory is not writable" 35msgid "directory is not writable"
36msgstr "le répertoire n'est pas accessible en écriture" 36msgstr "le répertoire n'est pas accessible en écriture"
37 37
38#: application/ApplicationUtils.php:215 38#: application/ApplicationUtils.php:216
39msgid "file is not readable" 39msgid "file is not readable"
40msgstr "le fichier n'est pas accessible en lecture" 40msgstr "le fichier n'est pas accessible en lecture"
41 41
42#: application/ApplicationUtils.php:218 42#: application/ApplicationUtils.php:219
43msgid "file is not writable" 43msgid "file is not writable"
44msgstr "le fichier n'est pas accessible en écriture" 44msgstr "le fichier n'est pas accessible en écriture"
45 45
@@ -58,11 +58,11 @@ msgstr "Liens directs"
58msgid "Permalink" 58msgid "Permalink"
59msgstr "Permalien" 59msgstr "Permalien"
60 60
61#: application/History.php:158 61#: application/History.php:174
62msgid "History file isn't readable or writable" 62msgid "History file isn't readable or writable"
63msgstr "Le fichier d'historique n'est pas accessible en lecture ou en écriture" 63msgstr "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
66msgid "Could not parse history file" 66msgid "Could not parse history file"
67msgstr "Format incorrect pour le fichier d'historique" 67msgstr "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
139msgid "The link you are trying to reach does not exist or has been deleted." 139msgid "The link you are trying to reach does not exist or has been deleted."
140msgstr "Le lien que vous essayez de consulter n'existe pas ou a été supprimé." 140msgstr "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é.
143msgid "Invalid export selection:" 143msgid "Invalid export selection:"
144msgstr "Sélection d'export invalide :" 144msgstr "Sélection d'export invalide :"
145 145
146#: application/NetscapeBookmarkUtils.php:80 146#: application/NetscapeBookmarkUtils.php:81
147#, php-format 147#, php-format
148msgid "File %s (%d bytes) " 148msgid "File %s (%d bytes) "
149msgstr "Le fichier %s (%d octets) " 149msgstr "Le fichier %s (%d octets) "
150 150
151#: application/NetscapeBookmarkUtils.php:82 151#: application/NetscapeBookmarkUtils.php:83
152msgid "has an unknown file format. Nothing was imported." 152msgid "has an unknown file format. Nothing was imported."
153msgstr "a un format inconnu. Rien n'a été importé." 153msgstr "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
157msgid "" 157msgid ""
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."
160msgstr "" 160msgstr ""
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
165msgid "The page you are trying to reach does not exist or has been deleted." 165msgid "The page you are trying to reach does not exist or has been deleted."
166msgstr "La page que vous essayez de consulter n'existe pas ou a été supprimée." 166msgstr "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
169msgid "404 Not Found" 169msgid "404 Not Found"
170msgstr "404 Introuvable" 170msgstr "404 Introuvable"
171 171
@@ -249,58 +249,62 @@ msgstr "Vous n'êtes pas autorisé à modifier la configuration."
249msgid "Error accessing" 249msgid "Error accessing"
250msgstr "Une erreur s'est produite en accédant à" 250msgstr "Une erreur s'est produite en accédant à"
251 251
252#: index.php:134 252#: index.php:133
253msgid "Shared links on " 253msgid "Shared links on "
254msgstr "Liens partagés sur " 254msgstr "Liens partagés sur "
255 255
256#: index.php:156 256#: index.php:155
257msgid "Insufficient permissions:" 257msgid "Insufficient permissions:"
258msgstr "Permissions insuffisantes :" 258msgstr "Permissions insuffisantes :"
259 259
260#: index.php:383 260#: index.php:382
261msgid "I said: NO. You are banned for the moment. Go away." 261msgid "I said: NO. You are banned for the moment. Go away."
262msgstr "NON. Vous êtes banni pour le moment. Revenez plus tard." 262msgstr "NON. Vous êtes banni pour le moment. Revenez plus tard."
263 263
264#: index.php:448 264#: index.php:447
265msgid "Wrong login/password." 265msgid "Wrong login/password."
266msgstr "Nom d'utilisateur ou mot de passe incorrects." 266msgstr "Nom d'utilisateur ou mot de passe incorrects."
267 267
268#: index.php:1091 268#: index.php:1107
269msgid "You are not supposed to change a password on an Open Shaarli." 269msgid "You are not supposed to change a password on an Open Shaarli."
270msgstr "" 270msgstr ""
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
274msgid "Wrong token." 274msgid "Wrong token."
275msgstr "Jeton invalide." 275msgstr "Jeton invalide."
276 276
277#: index.php:1101 277#: index.php:1117
278msgid "The old password is not correct." 278msgid "The old password is not correct."
279msgstr "L'ancien mot de passe est incorrect." 279msgstr "L'ancien mot de passe est incorrect."
280 280
281#: index.php:1121 281#: index.php:1137
282msgid "Your password has been changed" 282msgid "Your password has been changed"
283msgstr "Votre mot de passe a été modifié" 283msgstr "Votre mot de passe a été modifié"
284 284
285#: index.php:1174 285#: index.php:1190
286msgid "Configuration was saved." 286msgid "Configuration was saved."
287msgstr "La configuration a été sauvegardé." 287msgstr "La configuration a été sauvegardé."
288 288
289#: index.php:1225 289#: index.php:1241
290#, php-format 290#, php-format
291msgid "The tag was removed from %d link." 291msgid "The tag was removed from %d link."
292msgid_plural "The tag was removed from %d links." 292msgid_plural "The tag was removed from %d links."
293msgstr[0] "Le tag a été supprimé de %d lien." 293msgstr[0] "Le tag a été supprimé de %d lien."
294msgstr[1] "Le tag a été supprimé de %d liens." 294msgstr[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
298msgid "The tag was renamed in %d link." 298msgid "The tag was renamed in %d link."
299msgid_plural "The tag was renamed in %d links." 299msgid_plural "The tag was renamed in %d links."
300msgstr[0] "Le tag a été renommé dans %d lien." 300msgstr[0] "Le tag a été renommé dans %d lien."
301msgstr[1] "Le tag a été renommé dans %d liens." 301msgstr[1] "Le tag a été renommé dans %d liens."
302 302
303#: index.php:1551 303#: index.php:1458
304msgid "Note: "
305msgstr "Note : "
306
307#: index.php:1567
304#, php-format 308#, php-format
305msgid "" 309msgid ""
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
315msgid "" 319msgid ""
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
333msgid "Click to try again." 337msgid "Click to try again."
334msgstr "Cliquer ici pour réessayer." 338msgstr "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
17use 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 */
27const 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 */
32function 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)
160function hook_demo_plugin_render_footer($data) 186function 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 @@
1msgid ""
2msgstr ""
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
20msgid "Shaarli is now enhanced by the awesome demo_plugin."
21msgstr "Shaarli est maintenant amélioré avec le fantastique demo_plugin."