From cbcae4037c02cd6c1ce7c373c6dae390565b7c51 Mon Sep 17 00:00:00 2001 From: Maryana Rozhankivska Date: Wed, 26 Feb 2014 15:43:49 +0200 Subject: [PATCH] translation related: how-to md file added, script to generate php from all twig templates, polish mo file compiled --- TRANSLATION.md | 67 ++++++++++++++++++++ inc/poche/Poche.class.php | 6 +- locale/pl_PL.utf8/LC_MESSAGES/pl_PL.utf8.mo | Bin 11248 -> 11935 bytes locale/tools/fillCache.php | 59 +++++++++++++++++ 4 files changed, 129 insertions(+), 3 deletions(-) create mode 100755 TRANSLATION.md create mode 100755 locale/tools/fillCache.php diff --git a/TRANSLATION.md b/TRANSLATION.md new file mode 100755 index 00000000..2ea9279e --- /dev/null +++ b/TRANSLATION.md @@ -0,0 +1,67 @@ +# How to manage translations of wallabag + +This guide will describe procedure of translation management of wallabag web application. + +All translation are made using [gettext](http://en.wikipedia.org/wiki/Gettext) system and tools. + +You 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. + +You 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. + +**It's assumed, that you have wallabag installed locally on your computer or on the server you have access to.** + +## To change existing translation you will need to do: + +### 1. Clear cache +You 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) + +OR + +from command line: +go to root of your installation of wallabag project and run next command: + +`rm -rf ./cache/*` + +(this may require root privileges if you run, for example Apatche web server with mod_php) + +### 2. Generate php files from all twig templates +Do this using next command: + +`php ./locale/tools/fillCache.php` + +OR + +from your browser: **http://your-wallabag-host.com/locale/tools/fillCache.php** (this may require removal of .htacces file in locale/ directory). + +### 3. Configure your Poedit +Open Poedit editor, open Edit->Preferences. Go to "Parsers" tab, click on PHP and press "Edit" button. Make sure your "Parser command:" looks like + +`xgettext --no-location --force-po -o %o %C %K %F` + +Usualy it is required to add "--no-location" to default value. + +### 4. Open .po file you want to edit in Poedit and change it's settings +Open, for example `locale/pl_PL.utf8/LC_MESSAGES/pl_PL.utf8.po` file in your Poedit. + +Go 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. + +You can also check "project into" tab to be sure, that "Language" is set correctly (this will allow you to spell check your translation). + +### 5. Update opened .po file from sources +Once 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. + +As 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). + +### 6. Translate and save your .po file +If you have any dificulties on this step, please consult with Poedit manual. +Every time you save your .po file, Poedit will also comple appropriate .mo file by default (of course, if not disabled in preferences). + +So, you are almost done. + +### 7. Clear cache again +This 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). + + +##To create new tanslation +Please simple create appropriate directories in locale folder and perform all steps, described above. Instead of opening an existing file just create new one. + 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 'pl_PL.utf8' => 'Polski', 'ru_RU.utf8' => 'Pусский', 'sl_SI.utf8' => 'Slovenščina', - 'uk_UA.utf8' => 'Український', + 'uk_UA.utf8' => 'Українська', ); public function __construct() { @@ -336,7 +336,7 @@ class Poche while (($language = readdir($handle)) !== false) { # Languages are stored in a directory, so all directory names are languages # @todo move language installation data to database - if (! is_dir(LOCALE . '/' . $language) || in_array($language, array('..', '.'))) { + if (! is_dir(LOCALE . '/' . $language) || in_array($language, array('..', '.', 'tools'))) { continue; } @@ -346,7 +346,7 @@ class Poche $current = true; } - $languages[] = array('name' => $this->language_names[$language], 'value' => $language, 'current' => $current); + $languages[] = array('name' => (isset($this->language_names[$language]) ? $this->language_names[$language] : $language), 'value' => $language, 'current' => $current); } 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 22985970c8722aa3d171c3c79dc2180e2595b92a..b363385ac3f3e30a95b3fa573cbc8258a817f186 100755 GIT binary patch delta 4805 zcmaKudvH|c8Hc|F5D2$OxG0e16YOwOXe`y+o~wtyD;DJ6L;>v9;8@qvKeorPDft{?X^RyJ=-?`_2B&^PY3Q z%lp3H`<>*k8}7e6`_{zayAADLGy@GEVa)I0r=z*h7LDT>Y=_lwDQtu`oC$ZrvG5r< z5xxw^z$0)Gd>2lJ)5aUa)TR~kGYhy(GA3(Qa;w;Z%4ntYv+(8$+JI09V6<@N77a zSryquP!4)fsoe%y)7%c_=mSs@{{RkyKZe?}{ZNq~fZD28pvE18Ww01;vWj2|#%wqP zo&wiEEfj!qEDAMI8fu~IAV1U3MeiSkn(&8kJ$wna!AU%9ge&0%(1W|+&!FaCKZ*P+ zHJyYv2S%VGx(_Oaj}-0)3fvDh@L=KnYfugxE!=+yHQzBPhqX^tU?kLi6I6h$P_?jn zGWl2JojlN<^g}uDDAb-m4mI$3sFWUn8aN2c;ZaDi<~Y>&alEX7by(!x*H_v*tF8X*{?eDy1(#Rp}ofbz(k-TIfrt3>4E@j*f=vHyJ(- z>mX~HBXBiE0?6~Vhusrw9Sq9RIL_fw%Fnh7_;v*79QKB&|17Q6zM z)ERRVbfLEH7*qySNGitaEQV5l4pgKULZv=jU;=94YoLmB7gVi02G##*C`Vo`JpTyF zkz-Ji&Se!jya*~|YoJa?Cse@M-57FUUxClUlem8g%Hy9yIq*8v)_ek0R3jVn4o!z- z-^_)I>>{XRoP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52mXjNtrlxK#Jq zVQP0ZGW#Zunz?JCY*tq0hMu|9R+cz$5FQ*T!InQk|sx9tN?*uL&uI=*x( z6C3DrqDd#~CKB!zx5J(YPqFoN)iztVc61MyGfJe(wI}OZYRUKV@Fr zF4^{`d1VQEf784X!4kOk?WP(#J2b8Qwdd^SQ0LI%>e`=$rdC9~TkS`on(}U=&IO`AC>?`C2N*Uverbl%I;uZ;RJ*VxXMnuR8tW9ech zn?BnAza#tit8ThG*V!}J+jGACZ%k`%XE6C(r?wW~3Y$0Y#?I|fKS%3PH|{yby*YTq zbGo#r{@=rinBVE7l6Lv@Z`sS5H`e4L|N0b+vL5Um*cHh$*wPx`+x!G;+}5&ST%^=N zo@MFm>GJ$;=Ge7+T5fJ6t!OgSJisDir() and $tplDir!='.' and $tplDir!='..') { + echo "\n$tplDir\n"; + + $loader = new Twig_Loader_Filesystem($tplDirRoot.$tplDir); + + // force auto-reload to always have the latest version of the template + $twig = new Twig_Environment($loader, array( + 'cache' => $tmpDir, + 'auto_reload' => true + )); + + $twig->addExtension(new Twig_Extensions_Extension_I18n()); + + $filter = new Twig_SimpleFilter('getDomain', 'Tools::getDomain'); + $twig->addFilter($filter); + + $filter = new Twig_SimpleFilter('getReadingTime', 'Tools::getReadingTime'); + $twig->addFilter($filter); + + $filter = new Twig_SimpleFilter('getPrettyFilename', function($string) { return str_replace($siteRoot, '', $string); }); + $twig->addFilter($filter); + +// // iterate over all your templates + foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tplDirRoot.$tplDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) { + // force compilation + if ($file->isFile() and pathinfo($file, PATHINFO_EXTENSION)=='twig') { + echo "\t$file\n"; + $twig->loadTemplate(str_replace($tplDirRoot.$tplDir.'/', '', $file)); + } + } + + } + + } + -- 2.41.0