PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.1
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.1
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / src / helpers / language-helper.php

language-helper.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.1, at src/helpers/language-helper.php

56 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Yoast\WP\SEO\Helpers;
4
5 use WPSEO_Language_Utils;
6 use Yoast\WP\SEO\Config\Researcher_Languages;
7
8 /**
9 * A helper object for language features.
10 */
11 class Language_Helper {
12
13 /**
14 * Checks whether word form recognition is active for the used language.
15 *
16 * @param string $language The used language.
17 *
18 * @return bool Whether word form recognition is active for the used language.
19 */
20 public function is_word_form_recognition_active( $language ) {
21 $supported_languages = [ 'de', 'en', 'es', 'fr', 'it', 'nl', 'ru', 'id', 'pt', 'pl', 'ar', 'sv', 'he', 'hu', 'nb', 'tr', 'cs', 'sk', 'el', 'ja' ];
22
23 return \in_array( $language, $supported_languages, true );
24 }
25
26 /**
27 * Checks whether the given language has function word support.
28 * (E.g. function words are used or filtered out for this language when doing some SEO and readability assessments).
29 *
30 * @param string $language The language to check.
31 *
32 * @return bool Whether the language has function word support.
33 */
34 public function has_function_word_support( $language ) {
35 $supported_languages = [ 'en', 'de', 'nl', 'fr', 'es', 'it', 'pt', 'ru', 'pl', 'sv', 'id', 'he', 'ar', 'hu', 'nb', 'tr', 'cs', 'sk', 'fa', 'el', 'ja' ];
36
37 return \in_array( $language, $supported_languages, true );
38 }
39
40 /**
41 * Checks whether we have a specific researcher for the current locale and returns that language.
42 * If there is no researcher for the current locale, returns default as the researcher.
43 *
44 * @return string The language to use to select a researcher.
45 */
46 public function get_researcher_language() {
47 $researcher_language = WPSEO_Language_Utils::get_language( \get_locale() );
48 $supported_languages = Researcher_Languages::SUPPORTED_LANGUAGES;
49
50 if ( ! \in_array( $researcher_language, $supported_languages, true ) ) {
51 $researcher_language = 'default';
52 }
53 return $researcher_language;
54 }
55 }
56