mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 14:35:55 +00:00
support per-plugin locale directories
This commit is contained in:
@@ -1,4 +1,18 @@
|
||||
<?php
|
||||
/* gettext helpers for plugins */
|
||||
|
||||
function P__($plugin, $msgid) {
|
||||
return P_gettext($plugin, $msgid);
|
||||
}
|
||||
|
||||
function P_gettext($plugin, $msgid) {
|
||||
return _dgettext(PLuginHost::object_to_domain($plugin), $msgid);
|
||||
}
|
||||
|
||||
function P_ngettext($plugin, $singular, $plural, $number) {
|
||||
return _dngettext(PLuginHost::object_to_domain($plugin), $singular, $plural, $number);
|
||||
}
|
||||
|
||||
class PluginHost {
|
||||
private $pdo;
|
||||
private $hooks = array();
|
||||
@@ -63,6 +77,10 @@ class PluginHost {
|
||||
const KIND_SYSTEM = 2;
|
||||
const KIND_USER = 3;
|
||||
|
||||
static function object_to_domain($plugin) {
|
||||
return strtolower(get_class($plugin));
|
||||
}
|
||||
|
||||
function __construct() {
|
||||
$this->pdo = Db::pdo();
|
||||
|
||||
@@ -211,6 +229,11 @@ class PluginHost {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file_exists(dirname($file) . "/locale")) {
|
||||
_bindtextdomain($class, dirname($file) . "/locale");
|
||||
_bind_textdomain_codeset($class, "UTF-8");
|
||||
}
|
||||
|
||||
$this->last_registered = $class;
|
||||
|
||||
switch ($kind) {
|
||||
|
||||
Reference in New Issue
Block a user