mirror of
https://github.com/inretio/WordPress-Plugin-Boilerplate
synced 2024-12-22 11:53:53 +02:00
de-subclassing this class and defining a domain attribute provided by setter injection
This commit is contained in:
parent
0d63ec21e5
commit
9a23715ba7
1 changed files with 11 additions and 7 deletions
|
@ -20,9 +20,10 @@
|
||||||
* @package Plugin_Name
|
* @package Plugin_Name
|
||||||
* @subpackage Plugin_Name/includes
|
* @subpackage Plugin_Name/includes
|
||||||
* @author Your Name <email@example.com>
|
* @author Your Name <email@example.com>
|
||||||
* @extends Plugin_Name
|
|
||||||
*/
|
*/
|
||||||
class Plugin_Name_i18n extends Plugin_Name {
|
class Plugin_Name_i18n {
|
||||||
|
|
||||||
|
private $domain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -32,12 +33,15 @@ class Plugin_Name_i18n extends Plugin_Name {
|
||||||
*/
|
*/
|
||||||
public function load_plugin_textdomain() {
|
public function load_plugin_textdomain() {
|
||||||
|
|
||||||
$domain = $this->plugin_slug;
|
$locale = apply_filters( 'plugin_locale', get_locale(), $this->domain );
|
||||||
$locale = apply_filters( 'plugin_locale', get_locale(), $domain );
|
|
||||||
|
|
||||||
load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo' );
|
load_textdomain( $this->domain, trailingslashit( WP_LANG_DIR ) . $this->domain . '/' . $this->domain . '-' . $locale . '.mo' );
|
||||||
load_plugin_textdomain( $domain, FALSE, basename( plugin_dir_path( dirname( __FILE__ ) ) ) . '/languages/' );
|
load_plugin_textdomain( $this->domain, FALSE, basename( plugin_dir_path( dirname( __FILE__ ) ) ) . '/languages/' );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
public function set_domain( $domain ) {
|
||||||
|
$this->domain = $domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue