From 51777e75e843bab05b6fdce5fead6cd0bf46ee97 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 1 Mar 2019 14:26:59 +0300 Subject: add gettext stuff --- init.js | 2 +- init.php | 10 ++++++++++ locale/ru_RU/LC_MESSAGES/time_to_read.mo | Bin 0 -> 712 bytes locale/ru_RU/LC_MESSAGES/time_to_read.po | 28 ++++++++++++++++++++++++++++ locale/ru_RU/LC_MESSAGES/time_to_read.po~ | 26 ++++++++++++++++++++++++++ time_to_read.pot | 26 ++++++++++++++++++++++++++ update-translations.sh | 28 ++++++++++++++++++++++++++++ 7 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 locale/ru_RU/LC_MESSAGES/time_to_read.mo create mode 100644 locale/ru_RU/LC_MESSAGES/time_to_read.po create mode 100644 locale/ru_RU/LC_MESSAGES/time_to_read.po~ create mode 100644 time_to_read.pot create mode 100755 update-translations.sh diff --git a/init.js b/init.js index abfc805..129571b 100644 --- a/init.js +++ b/init.js @@ -10,7 +10,7 @@ require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { const pr = document.createElement("span"); pr.className = 'time-to-read insensitive'; - pr.innerHTML = "Time to read: ~" + ttr + " minutes."; + pr.innerHTML = __("Time to read: ~%s minutes.").replace("%s", ttr); row.querySelector(".titleWrap").appendChild(pr); } diff --git a/init.php b/init.php index 8103739..33224f3 100644 --- a/init.php +++ b/init.php @@ -11,6 +11,7 @@ class Time_to_Read extends Plugin { function init($host) { $this->host = $host; + //$host->add_hook($host::HOOK_PREFS_TAB, $this); } function get_js() { @@ -25,4 +26,13 @@ class Time_to_Read extends Plugin { return 2; } + /*function hook_prefs_tab($args) { + if ($args != "prefPrefs") return; + + print "
photo ".P__($this, 'Test-Test')."\">"; + + print "
"; + + }*/ } diff --git a/locale/ru_RU/LC_MESSAGES/time_to_read.mo b/locale/ru_RU/LC_MESSAGES/time_to_read.mo new file mode 100644 index 0000000..47133ce Binary files /dev/null and b/locale/ru_RU/LC_MESSAGES/time_to_read.mo differ diff --git a/locale/ru_RU/LC_MESSAGES/time_to_read.po b/locale/ru_RU/LC_MESSAGES/time_to_read.po new file mode 100644 index 0000000..add0d50 --- /dev/null +++ b/locale/ru_RU/LC_MESSAGES/time_to_read.po @@ -0,0 +1,28 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +# +msgid "" +msgstr "" +"Project-Id-Version: tt-rss git\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-02-22 06:58+0300\n" +"PO-Revision-Date: 2019-02-07 14:36+0000\n" +"Last-Translator: Nikolay Korotkiy \n" +"Language-Team: Russian \n" +"Language: ru_RU\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" +"X-Generator: Weblate 3.3\n" + +#: init.php:33 +msgid "Test-Test" +msgstr "Тест-Тест" + +#: init.js:13 +msgid "Time to read: ~%s minutes." +msgstr "Время чтения: ~%s минут(ы)" diff --git a/locale/ru_RU/LC_MESSAGES/time_to_read.po~ b/locale/ru_RU/LC_MESSAGES/time_to_read.po~ new file mode 100644 index 0000000..ed0742c --- /dev/null +++ b/locale/ru_RU/LC_MESSAGES/time_to_read.po~ @@ -0,0 +1,26 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +# +msgid "" +msgstr "" +"Project-Id-Version: 1.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-03-01 13:37+0300\n" +"PO-Revision-Date: 2019-03-01 13:17+0300\n" +"Last-Translator: Andrew Dolgov \n" +"Language-Team: Russian \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: init.php:33 +msgid "Test" +msgstr "Тест" + +#: init.js:13 +msgid "Time to read: ~%s minutes." +msgstr "Время чтения: ~%s минут(ы)" diff --git a/time_to_read.pot b/time_to_read.pot new file mode 100644 index 0000000..64a9001 --- /dev/null +++ b/time_to_read.pot @@ -0,0 +1,26 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-03-01 14:08+0300\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: init.php:33 +msgid "Test-Test" +msgstr "" + +#: init.js:13 +msgid "Time to read: ~%s minutes." +msgstr "" diff --git a/update-translations.sh b/update-translations.sh new file mode 100755 index 0000000..8539e83 --- /dev/null +++ b/update-translations.sh @@ -0,0 +1,28 @@ +#!/bin/sh +TEMPLATE=time_to_read.pot + +xgettext -kT_js_decl -kT_sprintf -k_ngettext:1,2 -kT_ngettext:1,2 -k__ -L PHP -o $TEMPLATE *.php + +xgettext --from-code utf-8 -k__ -kNotify.info -kNotify.error -kNotify.progress -kngettext -L Perl -j -o $TEMPLATE *.js + +xgettext --from-code utf-8 -k__ -kNotify.info -kNotify.error -kNotify.progress -kngettext -L Java -j -o $TEMPLATE *.js + + +update_lang() { + if [ -f $1.po ]; then + msgmerge --no-wrap --width 1 -U $1.po $TEMPLATE + msgfmt --statistics $1.po -o $1.mo + else + echo "Usage: $0 [-p|]" + fi +} + +LANGS=`find locale -name 'time_to_read.po'` + +for lang in $LANGS; do + echo Updating $lang... + PO_BASENAME=`echo $lang | sed s/.po//` + update_lang $PO_BASENAME +done + +#./utils/update-js-translations.sh -- cgit v1.2.3