1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<?php
namespace BasicFullCalendar;
class PostType extends \PostTypes\PostType
{
public string $textdomain = '';
public string $textdomainDir;
public string $textdomainFile;
public static $defaultTextdomain = 'PostTypes/PostType';
public function textdomain($textdomain, $textdomainDir, $textdomainFile = '')
{
$this->textdomain = $textdomain;
$this->textdomainDir = $textdomainDir;
$this->textdomainFile = $textdomainFile ?: get_locale() . '.mo';
return $this;
}
public function register()
{
add_action('init', [$this, 'loadTextdomain']);
parent::register();
}
public function loadTextdomain()
{
load_textdomain(self::$defaultTextdomain, dirname(__DIR__) . '/languages/' . get_locale() . '.mo');
if (! empty($this->textdomain)) {
load_textdomain($this->textdomain, trailingslashit($this->textdomainDir) . $this->textdomainFile);
}
}
public function createLabels()
{
return array_replace_recursive([
'name' => __($this->plural, $this->textdomain),
'singular_name' => __($this->singular, $this->textdomain),
'menu_name' => __($this->plural, $this->textdomain),
'all_items' => __($this->plural, $this->textdomain),
'add_new' => __('Add New', self::$defaultTextdomain),
'add_new_item' => sprintf(__('Add New %s', self::$defaultTextdomain), __($this->singular, $this->textdomain)),
'edit_item' => sprintf(__('Edit %s', self::$defaultTextdomain), __($this->singular, $this->textdomain)),
'new_item' => sprintf(__('New %s', self::$defaultTextdomain), __($this->singular, $this->textdomain)),
'view_item' => sprintf(__('View %s', self::$defaultTextdomain), __($this->singular, $this->textdomain)),
'search_items' => sprintf(__('Search %s', self::$defaultTextdomain), $this->plural, $this->textdomain),
'not_found' => sprintf(__('No %s found', self::$defaultTextdomain), __($this->plural, $this->textdomain)),
'not_found_in_trash' => sprintf(__('No %s found in Trash', self::$defaultTextdomain), __($this->plural, $this->textdomain)),
'parent_item_colon' => sprintf(__('Parent %s:', self::$defaultTextdomain), __($this->singular, $this->textdomain)),
], $this->labels);
}
}
|