I18n   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 16
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A load_textdomain() 0 6 1
A register_hooks() 0 5 2
1
<?php declare(strict_types = 1);
2
3
namespace WPSteak\Providers;
4
5
class I18n extends HookProvider {
6
7
	public function register_hooks(): void {
8
		if ( did_action( 'plugins_loaded' ) ) {
9
			$this->load_textdomain();
10
		} else {
11
			$this->add_action( 'plugins_loaded', 'load_textdomain' );
12
		}
13
	}
14
15
	protected function load_textdomain(): void {
16
		$dir = dirname( dirname( __DIR__ ) ) . '/languages';
17
		$domain = 'wpsteak';
18
		$locale = get_locale();
19
20
		load_textdomain( $domain, "{$dir}/{$domain}-{$locale}.mo" );
21
	}
22
23
}
24