X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fplugin.php;h=f63bdf30936b1e08f96e44424630d11cecefc79a;hb=cb09b5c62adb8db5f57cd2f1c97ac024bcd01dc3;hp=2c77c3e120e134cac7ea5d54235b5852cab74655;hpb=1fd7e5e3794621993b01a5833faa8b6fa26c3847;p=quix0rs-gnu-social.git diff --git a/lib/plugin.php b/lib/plugin.php index 2c77c3e120..f63bdf3093 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,23 @@ 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); + bind_textdomain_codeset($name, 'UTF-8'); + } + } + } + protected function log($level, $msg) { common_log($level, get_class($this) . ': '.$msg); @@ -86,4 +105,16 @@ class Plugin { $this->log(LOG_DEBUG, $msg); } + + function onPluginVersion(&$versions) + { + $cls = get_class($this); + $name = mb_substr($cls, 0, -6); + + $versions[] = array('name' => $name, + 'version' => _('Unknown')); + + return true; + } } +