aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNicolas Lœuillet <nicolas@loeuillet.org>2014-02-26 14:56:15 +0100
committerNicolas Lœuillet <nicolas@loeuillet.org>2014-02-26 14:56:15 +0100
commit0e7f04b04ed73d4ef320948323742631a3d125e8 (patch)
treec9047a3c375eee5b8801283704e3803e0885d226
parent72f7ff058931806f9d0f2ca06d58c47264e33dfb (diff)
parentcbcae4037c02cd6c1ce7c373c6dae390565b7c51 (diff)
downloadwallabag-0e7f04b04ed73d4ef320948323742631a3d125e8.tar.gz
wallabag-0e7f04b04ed73d4ef320948323742631a3d125e8.tar.zst
wallabag-0e7f04b04ed73d4ef320948323742631a3d125e8.zip
Merge pull request #504 from mariroz/dev
translation related: how-to md file added, script to generate php from all twig templates, polish mo file compiled
-rwxr-xr-xTRANSLATION.md67
-rwxr-xr-xinc/poche/Poche.class.php6
-rwxr-xr-xlocale/pl_PL.utf8/LC_MESSAGES/pl_PL.utf8.mobin11248 -> 11935 bytes
-rwxr-xr-xlocale/tools/fillCache.php59
4 files changed, 129 insertions, 3 deletions
diff --git a/TRANSLATION.md b/TRANSLATION.md
new file mode 100755
index 00000000..2ea9279e
--- /dev/null
+++ b/TRANSLATION.md
@@ -0,0 +1,67 @@
1# How to manage translations of wallabag
2
3This guide will describe procedure of translation management of wallabag web application.
4
5All translation are made using [gettext](http://en.wikipedia.org/wiki/Gettext) system and tools.
6
7You will need [Poedit](http://www.poedit.net/download.php) editor to update, edit and create your translation files comfortably. In general, you can handle translations also without it: all can be done using gettext tools and your favorite plain text editor only. This guide, however, describes editing with Poedit. If you want to use gettext only, pls refer to xgettext manual page to update po files from sources (see also how it is used by Poedit below) and use msgunfmt tool to compile .mo files manually.
8
9You need to know, that translation phrases are stored in **".po"** files (for example: `locale/pl_PL.utf8/LC_MESSAGES/pl_PL.utf8.po`), which are then complied in **".mo"** files using **msgfmt** gettext tool or by Poedit, which will run msgfmt for you in background.
10
11**It's assumed, that you have wallabag installed locally on your computer or on the server you have access to.**
12
13## To change existing translation you will need to do:
14
15### 1. Clear cache
16You can do this using **http://your-wallabag-host.com/?empty-cache** link (replace http://your-wallabag-host.com/ with real url of your wallabag application)
17
18OR
19
20from command line:
21go to root of your installation of wallabag project and run next command:
22
23`rm -rf ./cache/*`
24
25(this may require root privileges if you run, for example Apatche web server with mod_php)
26
27### 2. Generate php files from all twig templates
28Do this using next command:
29
30`php ./locale/tools/fillCache.php`
31
32OR
33
34from your browser: **http://your-wallabag-host.com/locale/tools/fillCache.php** (this may require removal of .htacces file in locale/ directory).
35
36### 3. Configure your Poedit
37Open Poedit editor, open Edit->Preferences. Go to "Parsers" tab, click on PHP and press "Edit" button. Make sure your "Parser command:" looks like
38
39`xgettext --no-location --force-po -o %o %C %K %F`
40
41Usualy it is required to add "--no-location" to default value.
42
43### 4. Open .po file you want to edit in Poedit and change it's settings
44Open, for example `locale/pl_PL.utf8/LC_MESSAGES/pl_PL.utf8.po` file in your Poedit.
45
46Go to "Catalog"->"Settings..." menu. Go to "Path" tab and add path to wallabag installaion in your local file system. This step can't be ommited as you will not be able to update phrases otherwise.
47
48You can also check "project into" tab to be sure, that "Language" is set correctly (this will allow you to spell check your translation).
49
50### 5. Update opened .po file from sources
51Once you have set your path correctly, you are able to update phrases from sources. Press "Update catalog - synchronize it with sources" button or go to "Catalog"->"Update from sources" menu.
52
53As a result you will see confirmation popup with two tabs: "New strings" and "Obsolete strings". Pls review and accept changes (or press "Undo" if you see too many obsolete strings, as Poedit will remove them all - in this case please make sure all previous steps are performed w/o errors).
54
55### 6. Translate and save your .po file
56If you have any dificulties on this step, please consult with Poedit manual.
57Every time you save your .po file, Poedit will also comple appropriate .mo file by default (of course, if not disabled in preferences).
58
59So, you are almost done.
60
61### 7. Clear cache again
62This step may be required if your web server runs php scripts in name of, say, www user (i.e. Apache with mod_php, not cgi).
63
64
65##To create new tanslation
66Please simple create appropriate directories in locale folder and perform all steps, described above. Instead of opening an existing file just create new one.
67
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php
index 8a9de488..deec4226 100755
--- a/inc/poche/Poche.class.php
+++ b/inc/poche/Poche.class.php
@@ -34,7 +34,7 @@ class Poche
34 'pl_PL.utf8' => 'Polski', 34 'pl_PL.utf8' => 'Polski',
35 'ru_RU.utf8' => 'Pусский', 35 'ru_RU.utf8' => 'Pусский',
36 'sl_SI.utf8' => 'Slovenščina', 36 'sl_SI.utf8' => 'Slovenščina',
37 'uk_UA.utf8' => 'Українськй', 37 'uk_UA.utf8' => 'Українськ',
38 ); 38 );
39 public function __construct() 39 public function __construct()
40 { 40 {
@@ -336,7 +336,7 @@ class Poche
336 while (($language = readdir($handle)) !== false) { 336 while (($language = readdir($handle)) !== false) {
337 # Languages are stored in a directory, so all directory names are languages 337 # Languages are stored in a directory, so all directory names are languages
338 # @todo move language installation data to database 338 # @todo move language installation data to database
339 if (! is_dir(LOCALE . '/' . $language) || in_array($language, array('..', '.'))) { 339 if (! is_dir(LOCALE . '/' . $language) || in_array($language, array('..', '.', 'tools'))) {
340 continue; 340 continue;
341 } 341 }
342 342
@@ -346,7 +346,7 @@ class Poche
346 $current = true; 346 $current = true;
347 } 347 }
348 348
349 $languages[] = array('name' => $this->language_names[$language], 'value' => $language, 'current' => $current); 349 $languages[] = array('name' => (isset($this->language_names[$language]) ? $this->language_names[$language] : $language), 'value' => $language, 'current' => $current);
350 } 350 }
351 351
352 return $languages; 352 return $languages;
diff --git a/locale/pl_PL.utf8/LC_MESSAGES/pl_PL.utf8.mo b/locale/pl_PL.utf8/LC_MESSAGES/pl_PL.utf8.mo
index 22985970..b363385a 100755
--- a/locale/pl_PL.utf8/LC_MESSAGES/pl_PL.utf8.mo
+++ b/locale/pl_PL.utf8/LC_MESSAGES/pl_PL.utf8.mo
Binary files differ
diff --git a/locale/tools/fillCache.php b/locale/tools/fillCache.php
new file mode 100755
index 00000000..bdd9cc58
--- /dev/null
+++ b/locale/tools/fillCache.php
@@ -0,0 +1,59 @@
1<?php
2
3// this script compile all twig templates and put it in cahce to get Poedit (or xgettext) to extract phrases fron chached templates.
4
5// gettext command line tools:
6// msgunfmt - get po from mo
7// msgfmt - get mo from po
8// xgettext - extract phrases from files
9
10
11 $siteRoot = dirname(__FILE__) . '/../..';
12
13 require_once $siteRoot . '/vendor/twig/twig/lib/Twig/Autoloader.php';
14 Twig_Autoloader::register();
15
16 require_once $siteRoot . '/vendor/twig/extensions/lib/Twig/Extensions/Autoloader.php';
17 Twig_Extensions_Autoloader::register();
18
19 //$tplDir = $siteRoot.'/themes/default';
20 $tplDirRoot = $siteRoot.'/themes/';
21 $tmpDir = $siteRoot. '/cache/';
22
23 foreach (new IteratorIterator(new DirectoryIterator($tplDirRoot)) as $tplDir) {
24
25 if ($tplDir->isDir() and $tplDir!='.' and $tplDir!='..') {
26 echo "\n$tplDir\n";
27
28 $loader = new Twig_Loader_Filesystem($tplDirRoot.$tplDir);
29
30 // force auto-reload to always have the latest version of the template
31 $twig = new Twig_Environment($loader, array(
32 'cache' => $tmpDir,
33 'auto_reload' => true
34 ));
35
36 $twig->addExtension(new Twig_Extensions_Extension_I18n());
37
38 $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain');
39 $twig->addFilter($filter);
40
41 $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime');
42 $twig->addFilter($filter);
43
44 $filter = new Twig_SimpleFilter('getPrettyFilename', function($string) { return str_replace($siteRoot, '', $string); });
45 $twig->addFilter($filter);
46
47// // iterate over all your templates
48 foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tplDirRoot.$tplDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
49 // force compilation
50 if ($file->isFile() and pathinfo($file, PATHINFO_EXTENSION)=='twig') {
51 echo "\t$file\n";
52 $twig->loadTemplate(str_replace($tplDirRoot.$tplDir.'/', '', $file));
53 }
54 }
55
56 }
57
58 }
59