summaryrefslogtreecommitdiff
path: root/lib/plugin.php
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 /lib/plugin.php
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 'lib/plugin.php')
-rw-r--r--lib/plugin.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/plugin.php b/lib/plugin.php
index 2c77c3e12..de7313e59 100644
--- a/lib/plugin.php
+++ b/lib/plugin.php
@@ -65,6 +65,8 @@ class Plugin
Event::addHandler(mb_substr($method, 2), array($this, $method));
}
}
+
+ $this->setupGettext();
}
function initialize()
@@ -77,6 +79,22 @@ class Plugin
return true;
}
+ /**
+ * Checks if this plugin has localization that needs to be set up.
+ * Gettext localizations can be called via the _m() helper function.
+ */
+ protected function setupGettext()
+ {
+ $class = get_class($this);
+ if (substr($class, -6) == 'Plugin') {
+ $name = substr($class, 0, -6);
+ $path = INSTALLDIR . "/plugins/$name/locale";
+ if (file_exists($path) && is_dir($path)) {
+ bindtextdomain($name, $path);
+ }
+ }
+ }
+
protected function log($level, $msg)
{
common_log($level, get_class($this) . ': '.$msg);
@@ -87,3 +105,4 @@ class Plugin
$this->log(LOG_DEBUG, $msg);
}
}
+