summaryrefslogtreecommitdiff
path: root/lib/plugin.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-12-22 16:44:19 -0800
committerEvan Prodromou <evan@status.net>2009-12-22 16:44:19 -0800
commitf6bf9529805cd58fdd1671dd9b133bde05e8ae87 (patch)
treecf272bd1105da48f016b635db4d9c34810adcbda /lib/plugin.php
parentf987273f118a12d443b6789c2ab59d7a4b01f678 (diff)
parent30c2e2ce83282f0bc268153d7ec465fbb5cf00ca (diff)
Merge branch 'testing'
Diffstat (limited to 'lib/plugin.php')
-rw-r--r--lib/plugin.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/plugin.php b/lib/plugin.php
index 87d7be5a7..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()
@@ -76,4 +78,31 @@ 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);
+ }
+
+ protected function debug($msg)
+ {
+ $this->log(LOG_DEBUG, $msg);
+ }
}
+