+ /**
+ * Get the "parent" language which has a converter to convert a "compatible" language
+ * (in another variant) to this language (eg. zh for zh-cn, but not en for en-gb).
+ *
+ * @return Language|null
+ * @since 1.22
+ */
+ public function getParentLanguage() {
+ if ( $this->mParentLanguage !== false ) {
+ return $this->mParentLanguage;
+ }
+
+ $pieces = explode( '-', $this->getCode() );
+ $code = $pieces[0];
+ if ( !in_array( $code, LanguageConverter::$languagesWithVariants ) ) {
+ $this->mParentLanguage = null;
+ return null;
+ }
+ $lang = Language::factory( $code );
+ if ( !$lang->hasVariant( $this->getCode() ) ) {
+ $this->mParentLanguage = null;
+ return null;
+ }
+
+ $this->mParentLanguage = $lang;
+ return $lang;
+ }
+