summaryrefslogtreecommitdiff
path: root/plugins/FeedSub
diff options
context:
space:
mode:
authorBrion Vibber <brion@status.net>2009-12-08 12:17:11 -0800
committerBrion Vibber <brion@status.net>2009-12-08 12:17:11 -0800
commit4b5e977a7b1c390555d880d3dc7f8b8c6744646c (patch)
tree9aa0f21fdffcb8f737b28d8a676746735574944f /plugins/FeedSub
parent3536f01258dc43bee764c98fbdda5a6f1df7bcb2 (diff)
New _m() gettext wrapper with smart detection of plugin domains. Plugin base class registers your gettext files if present at initialization.
update_pot.sh replaced with update_po_templates.php which can do core, plugins, or all (default). Top-level Makefile added to build .mo files for plugins as well as core. As described on list: http://lists.status.net/pipermail/statusnet-dev/2009-December/002869.html
Diffstat (limited to 'plugins/FeedSub')
-rw-r--r--plugins/FeedSub/FeedSubPlugin.php5
-rw-r--r--plugins/FeedSub/actions/feedsubsettings.php40
-rw-r--r--plugins/FeedSub/feedmunger.php2
-rw-r--r--plugins/FeedSub/locale/FeedSub.po104
-rw-r--r--plugins/FeedSub/locale/fr/LC_MESSAGES/FeedSub.po106
-rw-r--r--plugins/FeedSub/tests/gettext-speedtest.php78
6 files changed, 310 insertions, 25 deletions
diff --git a/plugins/FeedSub/FeedSubPlugin.php b/plugins/FeedSub/FeedSubPlugin.php
index 36d4e7802..857a9794d 100644
--- a/plugins/FeedSub/FeedSubPlugin.php
+++ b/plugins/FeedSub/FeedSubPlugin.php
@@ -51,7 +51,6 @@ class FeedSubPlugin extends Plugin
* @param Net_URL_Mapper $m path-to-action mapper
* @return boolean hook return
*/
-
function onRouterInitialized($m)
{
$m->connect('feedsub/callback/:feed',
@@ -74,8 +73,8 @@ class FeedSubPlugin extends Plugin
$action_name = $action->trimmed('action');
$action->menuItem(common_local_url('feedsubsettings'),
- dgettext('FeebSubPlugin', 'Feeds'),
- dgettext('FeedSubPlugin', 'Feed subscription options'),
+ _m('Feeds'),
+ _m('Feed subscription options'),
$action_name === 'feedsubsettings');
return true;
diff --git a/plugins/FeedSub/actions/feedsubsettings.php b/plugins/FeedSub/actions/feedsubsettings.php
index 242224fac..0fba20a39 100644
--- a/plugins/FeedSub/actions/feedsubsettings.php
+++ b/plugins/FeedSub/actions/feedsubsettings.php
@@ -38,7 +38,7 @@ class FeedSubSettingsAction extends ConnectSettingsAction
function title()
{
- return dgettext('FeedSubPlugin', 'Feed subscriptions');
+ return _m('Feed subscriptions');
}
/**
@@ -49,9 +49,8 @@ class FeedSubSettingsAction extends ConnectSettingsAction
function getInstructions()
{
- return dgettext('FeedSubPlugin',
- 'You can subscribe to feeds from other sites; ' .
- 'updates will appear in your personal timeline.');
+ return _m('You can subscribe to feeds from other sites; ' .
+ 'updates will appear in your personal timeline.');
}
/**
@@ -94,9 +93,9 @@ class FeedSubSettingsAction extends ConnectSettingsAction
$this->elementEnd('ul');
if ($this->preview) {
- $this->submit('subscribe', dgettext('FeedSubPlugin', 'Subscribe'));
+ $this->submit('subscribe', _m('Subscribe'));
} else {
- $this->submit('validate', dgettext('FeedSubPlugin', 'Continue'));
+ $this->submit('validate', _m('Continue'));
}
$this->elementEnd('fieldset');
@@ -149,8 +148,7 @@ class FeedSubSettingsAction extends ConnectSettingsAction
$feedurl = trim($this->arg('feedurl'));
if ($feedurl == '') {
- $this->showForm(dgettext('FeedSubPlugin',
- 'Empty feed URL!'));
+ $this->showForm(_m('Empty feed URL!'));
return;
}
$this->feedurl = $feedurl;
@@ -160,26 +158,26 @@ class FeedSubSettingsAction extends ConnectSettingsAction
$discover = new FeedDiscovery();
$uri = $discover->discoverFromURL($feedurl);
} catch (FeedSubBadURLException $e) {
- $this->showForm(dgettext('FeedSubPlugin', 'Invalid URL or could not reach server.'));
+ $this->showForm(_m('Invalid URL or could not reach server.'));
return false;
} catch (FeedSubBadResponseException $e) {
- $this->showForm(dgettext('FeedSubPlugin', 'Cannot read feed; server returned error.'));
+ $this->showForm(_m('Cannot read feed; server returned error.'));
return false;
} catch (FeedSubEmptyException $e) {
- $this->showForm(dgettext('FeedSubPlugin', 'Cannot read feed; server returned an empty page.'));
+ $this->showForm(_m('Cannot read feed; server returned an empty page.'));
return false;
} catch (FeedSubBadHTMLException $e) {
- $this->showForm(dgettext('FeedSubPlugin', 'Bad HTML, could not find feed link.'));
+ $this->showForm(_m('Bad HTML, could not find feed link.'));
return false;
} catch (FeedSubNoFeedException $e) {
- $this->showForm(dgettext('FeedSubPlugin', 'Could not find a feed linked from this URL.'));
+ $this->showForm(_m('Could not find a feed linked from this URL.'));
return false;
} catch (FeedSubUnrecognizedTypeException $e) {
- $this->showForm(dgettext('FeedSubPlugin', 'Not a recognized feed type.'));
+ $this->showForm(_m('Not a recognized feed type.'));
return false;
} catch (FeedSubException $e) {
// Any new ones we forgot about
- $this->showForm(dgettext('FeedSubPlugin', 'Bad feed URL.'));
+ $this->showForm(_m('Bad feed URL.'));
return false;
}
@@ -187,7 +185,7 @@ class FeedSubSettingsAction extends ConnectSettingsAction
$this->feedinfo = $this->munger->feedInfo();
if ($this->feedinfo->huburi == '') {
- $this->showForm(dgettext('FeedSubPlugin', 'Feed is not PuSH-enabled; cannot subscribe.'));
+ $this->showForm(_m('Feed is not PuSH-enabled; cannot subscribe.'));
return false;
}
@@ -207,7 +205,7 @@ class FeedSubSettingsAction extends ConnectSettingsAction
$ok = $this->feedinfo->subscribe();
common_log(LOG_INFO, __METHOD__ . ": sub was $ok");
if (!$ok) {
- $this->showForm(dgettext('FeedSubPlugin', 'Feed subscription failed! Bad response from hub.'));
+ $this->showForm(_m('Feed subscription failed! Bad response from hub.'));
return;
}
}
@@ -217,11 +215,11 @@ class FeedSubSettingsAction extends ConnectSettingsAction
$profile = $this->feedinfo->getProfile();
if ($user->isSubscribed($profile)) {
- $this->showForm(dgettext('FeedSubPlugin', 'Already subscribed!'));
+ $this->showForm(_m('Already subscribed!'));
} elseif ($user->subscribeTo($profile)) {
- $this->showForm(dgettext('FeedSubPlugin', 'Feed subscribed!'));
+ $this->showForm(_m('Feed subscribed!'));
} else {
- $this->showForm(dgettext('FeedSubPlugin', 'Feed subscription failed!'));
+ $this->showForm(_m('Feed subscription failed!'));
}
}
}
@@ -230,7 +228,7 @@ class FeedSubSettingsAction extends ConnectSettingsAction
{
if ($this->validateFeed()) {
$this->preview = true;
- $this->showForm(dgettext('FeedSubPlugin', 'Previewing feed:'));
+ $this->showForm(_m('Previewing feed:'));
}
}
diff --git a/plugins/FeedSub/feedmunger.php b/plugins/FeedSub/feedmunger.php
index bb8075da9..f3618b8eb 100644
--- a/plugins/FeedSub/feedmunger.php
+++ b/plugins/FeedSub/feedmunger.php
@@ -212,7 +212,7 @@ class FeedMunger
// try adding #hashtags from the categories/tags on a post.
// @todo Should we force a language here?
- $format = dgettext("FeedSubPlugin", 'New post: "%1$s" %2$s');
+ $format = _m('New post: "%1$s" %2$s');
$title = $entry->title;
$link = $this->getAltLink($entry);
$out = sprintf($format, $title, $link);
diff --git a/plugins/FeedSub/locale/FeedSub.po b/plugins/FeedSub/locale/FeedSub.po
new file mode 100644
index 000000000..dedc018e3
--- /dev/null
+++ b/plugins/FeedSub/locale/FeedSub.po
@@ -0,0 +1,104 @@
+# 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 <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-12-07 20:38-0800\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: tests/gettext-speedtest.php:57 FeedSubPlugin.php:76
+msgid "Feeds"
+msgstr ""
+
+#: FeedSubPlugin.php:77
+msgid "Feed subscription options"
+msgstr ""
+
+#: feedmunger.php:215
+#, php-format
+msgid "New post: \"%1$s\" %2$s"
+msgstr ""
+
+#: actions/feedsubsettings.php:41
+msgid "Feed subscriptions"
+msgstr ""
+
+#: actions/feedsubsettings.php:52
+msgid ""
+"You can subscribe to feeds from other sites; updates will appear in your "
+"personal timeline."
+msgstr ""
+
+#: actions/feedsubsettings.php:96
+msgid "Subscribe"
+msgstr ""
+
+#: actions/feedsubsettings.php:98
+msgid "Continue"
+msgstr ""
+
+#: actions/feedsubsettings.php:151
+msgid "Empty feed URL!"
+msgstr ""
+
+#: actions/feedsubsettings.php:161
+msgid "Invalid URL or could not reach server."
+msgstr ""
+
+#: actions/feedsubsettings.php:164
+msgid "Cannot read feed; server returned error."
+msgstr ""
+
+#: actions/feedsubsettings.php:167
+msgid "Cannot read feed; server returned an empty page."
+msgstr ""
+
+#: actions/feedsubsettings.php:170
+msgid "Bad HTML, could not find feed link."
+msgstr ""
+
+#: actions/feedsubsettings.php:173
+msgid "Could not find a feed linked from this URL."
+msgstr ""
+
+#: actions/feedsubsettings.php:176
+msgid "Not a recognized feed type."
+msgstr ""
+
+#: actions/feedsubsettings.php:180
+msgid "Bad feed URL."
+msgstr ""
+
+#: actions/feedsubsettings.php:188
+msgid "Feed is not PuSH-enabled; cannot subscribe."
+msgstr ""
+
+#: actions/feedsubsettings.php:208
+msgid "Feed subscription failed! Bad response from hub."
+msgstr ""
+
+#: actions/feedsubsettings.php:218
+msgid "Already subscribed!"
+msgstr ""
+
+#: actions/feedsubsettings.php:220
+msgid "Feed subscribed!"
+msgstr ""
+
+#: actions/feedsubsettings.php:222
+msgid "Feed subscription failed!"
+msgstr ""
+
+#: actions/feedsubsettings.php:231
+msgid "Previewing feed:"
+msgstr ""
diff --git a/plugins/FeedSub/locale/fr/LC_MESSAGES/FeedSub.po b/plugins/FeedSub/locale/fr/LC_MESSAGES/FeedSub.po
new file mode 100644
index 000000000..f17dfa50a
--- /dev/null
+++ b/plugins/FeedSub/locale/fr/LC_MESSAGES/FeedSub.po
@@ -0,0 +1,106 @@
+# 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 <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2009-12-07 14:14-0800\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: FeedSubPlugin.php:77
+msgid "Feeds"
+msgstr "Flux"
+
+#: FeedSubPlugin.php:78
+msgid "Feed subscription options"
+msgstr "Préférences pour abonnement flux"
+
+#: feedmunger.php:215
+#, php-format
+msgid "New post: \"%1$s\" %2$s"
+msgstr "Nouveau: \"%1$s\" %2$s"
+
+#: actions/feedsubsettings.php:41
+msgid "Feed subscriptions"
+msgstr "Abonnements aux fluxes"
+
+#: actions/feedsubsettings.php:52
+msgid ""
+"You can subscribe to feeds from other sites; updates will appear in your "
+"personal timeline."
+msgstr ""
+"Abonner aux fluxes RSS ou Atom des autres sites web; les temps se trouverair"
+"en votre flux personnel."
+
+#: actions/feedsubsettings.php:96
+msgid "Subscribe"
+msgstr "Abonner"
+
+#: actions/feedsubsettings.php:98
+msgid "Continue"
+msgstr "Prochaine"
+
+#: actions/feedsubsettings.php:151
+msgid "Empty feed URL!"
+msgstr ""
+
+#: actions/feedsubsettings.php:161
+msgid "Invalid URL or could not reach server."
+msgstr ""
+
+#: actions/feedsubsettings.php:164
+msgid "Cannot read feed; server returned error."
+msgstr ""
+
+#: actions/feedsubsettings.php:167
+msgid "Cannot read feed; server returned an empty page."
+msgstr ""
+
+#: actions/feedsubsettings.php:170
+msgid "Bad HTML, could not find feed link."
+msgstr ""
+
+#: actions/feedsubsettings.php:173
+msgid "Could not find a feed linked from this URL."
+msgstr ""
+
+#: actions/feedsubsettings.php:176
+msgid "Not a recognized feed type."
+msgstr ""
+
+#: actions/feedsubsettings.php:180
+msgid "Bad feed URL."
+msgstr ""
+
+#: actions/feedsubsettings.php:188
+msgid "Feed is not PuSH-enabled; cannot subscribe."
+msgstr ""
+
+#: actions/feedsubsettings.php:208
+msgid "Feed subscription failed! Bad response from hub."
+msgstr ""
+
+#: actions/feedsubsettings.php:218
+msgid "Already subscribed!"
+msgstr ""
+
+#: actions/feedsubsettings.php:220
+msgid "Feed subscribed!"
+msgstr ""
+
+#: actions/feedsubsettings.php:222
+msgid "Feed subscription failed!"
+msgstr ""
+
+#: actions/feedsubsettings.php:231
+msgid "Previewing feed:"
+msgstr ""
diff --git a/plugins/FeedSub/tests/gettext-speedtest.php b/plugins/FeedSub/tests/gettext-speedtest.php
new file mode 100644
index 000000000..8bbdf5e89
--- /dev/null
+++ b/plugins/FeedSub/tests/gettext-speedtest.php
@@ -0,0 +1,78 @@
+<?php
+
+if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
+ print "This script must be run from the command line\n";
+ exit();
+}
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..'));
+define('STATUSNET', true);
+define('LACONICA', true);
+
+require_once INSTALLDIR . '/scripts/commandline.inc';
+require_once INSTALLDIR . '/extlib/php-gettext/gettext.inc';
+
+common_init_locale("en_US");
+common_init_locale('fr');
+
+
+putenv("LANG=fr");
+putenv("LANGUAGE=fr");
+setlocale('fr.utf8');
+_setlocale('fr.utf8');
+
+_bindtextdomain("statusnet", INSTALLDIR . '/locale');
+_bindtextdomain("FeedSub", INSTALLDIR . '/plugins/FeedSub/locale');
+
+$times = 10000;
+$delta = array();
+
+$start = microtime(true);
+for($i = 0; $i < $times; $i++) {
+ $result = _("Send");
+}
+$delta["_"] = array((microtime(true) - $start) / $times, $result);
+
+$start = microtime(true);
+for($i = 0; $i < $times; $i++) {
+ $result = __("Send");
+}
+$delta["__"] = array((microtime(true) - $start) / $times, $result);
+
+$start = microtime(true);
+for($i = 0; $i < $times; $i++) {
+ $result = dgettext("FeedSub", "Feeds");
+}
+$delta["dgettext"] = array((microtime(true) - $start) / $times, $result);
+
+$start = microtime(true);
+for($i = 0; $i < $times; $i++) {
+ $result = _dgettext("FeedSub", "Feeds");
+}
+$delta["_dgettext"] = array((microtime(true) - $start) / $times, $result);
+
+
+$start = microtime(true);
+for($i = 0; $i < $times; $i++) {
+ $result = _m("Feeds");
+}
+$delta["_m"] = array((microtime(true) - $start) / $times, $result);
+
+
+$start = microtime(true);
+for($i = 0; $i < $times; $i++) {
+ $result = fake("Feeds");
+}
+$delta["fake"] = array((microtime(true) - $start) / $times, $result);
+
+foreach ($delta as $func => $bits) {
+ list($time, $result) = $bits;
+ $ms = $time * 1000.0;
+ printf("%10s %2.4fms %s\n", $func, $ms, $result);
+}
+
+
+function fake($str) {
+ return $str;
+}
+