first
This commit is contained in:
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Translation;
|
||||
|
||||
abstract class AbstractTranslation {
|
||||
|
||||
public function _($text) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
public function getLocale() {
|
||||
return 'en_US';
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Translation;
|
||||
|
||||
use Nextend\Framework\Pattern\SingletonTrait;
|
||||
|
||||
class Translation {
|
||||
|
||||
use SingletonTrait;
|
||||
|
||||
/**
|
||||
* @var AbstractTranslation
|
||||
*/
|
||||
private static $platformTranslation;
|
||||
|
||||
public function __construct() {
|
||||
self::$platformTranslation = new WordPress\WordPressTranslation();
|
||||
}
|
||||
|
||||
public static function _($text) {
|
||||
return self::$platformTranslation->_($text);
|
||||
}
|
||||
|
||||
public static function getCurrentLocale() {
|
||||
return self::$platformTranslation->getLocale();
|
||||
}
|
||||
}
|
||||
|
||||
Translation::getInstance();
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Nextend\Framework\Translation\WordPress;
|
||||
|
||||
use Nextend\Framework\Translation\AbstractTranslation;
|
||||
|
||||
class WordPressTranslation extends AbstractTranslation {
|
||||
|
||||
public function __construct() {
|
||||
|
||||
if (defined('QTRANSLATE_FILE')) {
|
||||
add_filter('nextend_translation', 'qtranxf_useCurrentLanguageIfNotFoundShowAvailable', 0);
|
||||
}
|
||||
}
|
||||
|
||||
public function _($text) {
|
||||
return apply_filters('nextend_translation', $text);
|
||||
}
|
||||
|
||||
public function getLocale() {
|
||||
return is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user