Browse Source

pluginhost: remove plugin gettext helpers (moved to plugin base class)

Andrew Dolgov 1 year ago
parent
commit
614a4b3b4a
2 changed files with 18 additions and 23 deletions
  1. 18 1
      classes/plugin.php
  2. 0 22
      classes/pluginhost.php

+ 18 - 1
classes/plugin.php

@@ -40,4 +40,21 @@ abstract class Plugin {
 	function api_version() {
 		return Plugin::API_VERSION_COMPAT;
 	}
-}
+
+	/* gettext-related helpers */
+
+	function __($msgid) {
+		return _dgettext(PluginHost::object_to_domain($this), $msgid);
+	}
+
+	function _ngettext($singular, $plural, $number) {
+		return _dngettext(PluginHost::object_to_domain($this), $singular, $plural, $number);
+	}
+
+	function T_sprintf() {
+		$args = func_get_args();
+		$msgid = array_shift($args);
+
+		return vsprintf($this->__($msgid), $args);
+	}
+}

+ 0 - 22
classes/pluginhost.php

@@ -1,26 +1,4 @@
 <?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);
-}
-
-function P_sprintf() {
-	$args = func_get_args();
-	$plugin = array_shift($args);
-	$msgid = array_shift($args);
-
-	return vsprintf(P__($plugin, $msgid), $args);
-}
-
 class PluginHost {
 	private $pdo;
 	private $hooks = array();