/** * Add ISO 639-1 language code to the URL * * @param string $language iso code of the language * * @return $this * * @throws \Genesis\Exceptions\InvalidArgument */ public function setLanguage($language = \Genesis\API\Constants\i18n::EN) { // Strip the input down to two letters $language = substr(strtolower($language), 0, 2); if (!\Genesis\API\Constants\i18n::isValidLanguageCode($language)) { throw new \Genesis\Exceptions\InvalidArgument('The provided argument is not a valid ISO-639-1 language code!'); } $this->setApiConfig('url', $this->buildRequestURL('wpf', sprintf('%s/wpf', $language), false)); return $this; }
/** * Get Magento Core Locale * @param string $default * @return string * @throws \Magento\Framework\Webapi\Exception */ public function getLocale($default = 'en') { $languageCode = strtolower($this->getLocaleResolver()->getLocale()); $languageCode = substr($languageCode, 0, 2); if (!\Genesis\API\Constants\i18n::isValidLanguageCode($languageCode)) { $languageCode = $default; } if (!\Genesis\API\Constants\i18n::isValidLanguageCode($languageCode)) { $this->throwWebApiException(__('The provided argument is not a valid ISO-639-1 language code ' . 'or is not supported by the Payment Gateway!')); } return $languageCode; }