Language.php
868 Bytes
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
<?php
namespace AIOSEO\Plugin\Common\Traits\Helpers;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Contains i18n and language (code) helper methods.
*
* @since 4.1.4
*/
trait Language {
/**
* Returns the language of the current response.
*
* @since 4.1.4
*
* @return string The language code.
*/
public function currentLanguageCode() {
global $wp_version;
if ( version_compare( $wp_version, '5.0', '<' ) ) {
return get_locale();
}
return determine_locale(); // phpcs:ignore AIOSEO.WpFunctionUse.NewFunctions.determine_localeFound
}
/**
* Returns the language of the current response in BCP 47 format.
*
* @since 4.1.4
*
* @return string The language code in BCP 47 format.
*/
public function currentLanguageCodeBCP47() {
return str_replace( '_', '-', $this->currentLanguageCode() );
}
}