D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
var
/
www
/
html
/
novonote_ant
/
adm
/
phpoffice
/
phpword
/
src
/
PhpWord
/
Style
/
Filename :
Language.php
back
Copy
<?php namespace PhpOffice\PhpWord\Style; use InvalidArgumentException; final class Language extends AbstractStyle { const EN_US = 'en-US'; const EN_US_ID = 1033; const EN_GB = 'en-GB'; const EN_GB_ID = 2057; const FR_FR = 'fr-FR'; const FR_FR_ID = 1036; const FR_BE = 'fr-BE'; const FR_BE_ID = 2060; const FR_CH = 'fr-CH'; const FR_CH_ID = 4108; const ES_ES = 'es-ES'; const ES_ES_ID = 3082; const DE_DE = 'de-DE'; const DE_DE_ID = 1031; const DE_CH = 'de-CH'; const DE_CH_ID = 2055; const HE_IL = 'he-IL'; const HE_IL_ID = 1037; const IT_IT = 'it-IT'; const IT_IT_ID = 1040; const IT_CH = 'it-CH'; const IT_CH_ID = 2064; const JA_JP = 'ja-JP'; const JA_JP_ID = 1041; const KO_KR = 'ko-KR'; const KO_KR_ID = 1042; const ZH_CN = 'zh-CN'; const ZH_CN_ID = 2052; const HI_IN = 'hi-IN'; const HI_IN_ID = 1081; const PT_BR = 'pt-BR'; const PT_BR_ID = 1046; const NL_NL = 'nl-NL'; const NL_NL_ID = 1043; const SV_SE = 'sv-SE'; const SV_SE_ID = 1053; const UK_UA = 'uk-UA'; const UK_UA_ID = 1058; const RU_RU = 'ru-RU'; const RU_RU_ID = 1049; private $langId; private ?string $latin = null; private ?string $eastAsia = null; private ?string $bidirectional = null; public function __construct(?string $latin = null, ?string $eastAsia = null, ?string $bidirectional = null) { if (!empty($latin)) { $this->setLatin($latin); } if (!empty($eastAsia)) { $this->setEastAsia($eastAsia); } if (!empty($bidirectional)) { $this->setBidirectional($bidirectional); } } public function setLatin(?string $latin): self { $this->latin = $this->validateLocale($latin); return $this; } public function getLatin(): ?string { return $this->latin; } public function setLangId($langId) { $this->langId = $langId; return $this; } public function getLangId() { return $this->langId; } public function setEastAsia($eastAsia) { $this->eastAsia = $this->validateLocale($eastAsia); return $this; } public function getEastAsia(): ?string { return $this->eastAsia; } public function setBidirectional($bidirectional) { $this->bidirectional = $this->validateLocale($bidirectional); return $this; } public function getBidirectional(): ?string { return $this->bidirectional; } private function validateLocale($locale) { // Converte null para string vazia $locale = $locale ?? ''; // Garante que seja string if (!is_string($locale)) { $locale = (string) $locale; } // Normaliza formato $locale = str_replace('_', '-', $locale); // Corrige erro de strlen(null) if (strlen($locale) === 2) { return strtolower($locale) . '-' . strtoupper($locale); } if ($locale === 'und') { return 'en-EN'; } if ($locale !== 'zxx' && strpos($locale, '-') === false) { throw new InvalidArgumentException($locale . ' is not a valid language code'); } return $locale; } }