YaWK  24.1
Yet another WebKit
YAWK\language Class Reference

The language class - support multilingual backend. More...

Public Member Functions

 getClientLanguage ()
 get and return client language More...
 
 getCurrentLanguage ($db, $referer)
 returns the currently set language More...
 
 getPathToLanguageFile ()
 Returns the path to the language file. More...
 
 getSupportedLanguages ()
 sets object supportedLanguages as array including all supported languages More...
 
 init ($db, $referer)
 initialize and return current language More...
 
 isSupported (string $currentLanguage)
 Check if a language is supported. This functions expect currentLanguage string in format "en-EN" or "en". More...
 
 setDefault (string $defaultLanguage)
 Set a language as default and load (set) it current language. More...
 
 setLanguage (string $currentLanguage)
 set client language and parse corresponding ini file to an array called $lang More...
 

Static Public Member Functions

static drawLanguageSelectOptions ()
 return options (inner html) for a language select field More...
 
static getCurrentLanguageStatic ()
 returns the currently set backend language, but is static callable More...
 
static inject (array $lang, string $pathToFile)
 allow plugins to inject language tags to $lang array More...
 

Public Attributes

 $currentFrontendLanguage
 
 $currentLanguage
 
 $currentLanguageGlobal
 
 $defaultLanguage
 
 $detectedLanguage
 
 $detectedLanguageGlobal
 
 $httpAcceptedLanguage
 
 $lang
 
 $pathToFile
 
 $supportedLanguages
 
 $supportedLanguagesGlobal
 

Detailed Description

The language class - support multilingual backend.

Get and set the backend language.

Language Support for Backend

The language files are located in
admin/language/lang-en-EN.ini

Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Version
1.0.0

Definition at line 16 of file language.php.

Member Function Documentation

◆ drawLanguageSelectOptions()

static YAWK\language::drawLanguageSelectOptions ( )
static

return options (inner html) for a language select field

Returns
string returns a string with all possible language options

Definition at line 478 of file language.php.

478  : string
479  {
480  return '<option value=""></option>
481  <option value="af">Afrikaans</option>
482  <option value="sq">Albanian - shqip</option>
483  <option value="am">Amharic - አማርኛ</option>
484  <option value="ar">Arabic - العربية</option>
485  <option value="an">Aragonese - aragonés</option>
486  <option value="hy">Armenian - հայերեն</option>
487  <option value="ast">Asturian - asturianu</option>
488  <option value="az">Azerbaijani - azərbaycan dili</option>
489  <option value="eu">Basque - euskara</option>
490  <option value="be">Belarusian - беларуская</option>
491  <option value="bn">Bengali - বাংলা</option>
492  <option value="bs">Bosnian - bosanski</option>
493  <option value="br">Breton - brezhoneg</option>
494  <option value="bg">Bulgarian - български</option>
495  <option value="ca">Catalan - català</option>
496  <option value="ckb">Central Kurdish - کوردی (دەستنوسی عەرەبی)</option>
497  <option value="zh">Chinese - 中文</option>
498  <option value="zh-HK">Chinese (Hong Kong) - 中文(香港)</option>
499  <option value="zh-CN">Chinese (Simplified) - 中文(简体)</option>
500  <option value="zh-TW">Chinese (Traditional) - 中文(繁體)</option>
501  <option value="co">Corsican</option>
502  <option value="hr">Croatian - hrvatski</option>
503  <option value="cs">Czech - čeština</option>
504  <option value="da">Danish - dansk</option>
505  <option value="nl">Dutch - Nederlands</option>
506  <option value="en">English</option>
507  <option value="en-AU">English (Australia)</option>
508  <option value="en-CA">English (Canada)</option>
509  <option value="en-IN">English (India)</option>
510  <option value="en-NZ">English (New Zealand)</option>
511  <option value="en-ZA">English (South Africa)</option>
512  <option value="en-GB">English (United Kingdom)</option>
513  <option value="en-US">English (United States)</option>
514  <option value="eo">Esperanto - esperanto</option>
515  <option value="et">Estonian - eesti</option>
516  <option value="fo">Faroese - føroyskt</option>
517  <option value="fil">Filipino</option>
518  <option value="fi">Finnish - suomi</option>
519  <option value="fr">French - français</option>
520  <option value="fr-CA">French (Canada) - français (Canada)</option>
521  <option value="fr-FR">French (France) - français (France)</option>
522  <option value="fr-CH">French (Switzerland) - français (Suisse)</option>
523  <option value="gl">Galician - galego</option>
524  <option value="ka">Georgian - ქართული</option>
525  <option value="de">German - Deutsch</option>
526  <option value="de-AT">German (Austria) - Deutsch (Österreich)</option>
527  <option value="de-DE">German (Germany) - Deutsch (Deutschland)</option>
528  <option value="de-LI">German (Liechtenstein) - Deutsch (Liechtenstein)</option>
529  <option value="de-CH">German (Switzerland) - Deutsch (Schweiz)</option>
530  <option value="el">Greek - Ελληνικά</option>
531  <option value="gn">Guarani</option>
532  <option value="gu">Gujarati - ગુજરાતી</option>
533  <option value="ha">Hausa</option>
534  <option value="haw">Hawaiian - ʻŌlelo Hawaiʻi</option>
535  <option value="he">Hebrew - עברית</option>
536  <option value="hi">Hindi - हिन्दी</option>
537  <option value="hu">Hungarian - magyar</option>
538  <option value="is">Icelandic - íslenska</option>
539  <option value="id">Indonesian - Indonesia</option>
540  <option value="ia">Interlingua</option>
541  <option value="ga">Irish - Gaeilge</option>
542  <option value="it">Italian - italiano</option>
543  <option value="it-IT">Italian (Italy) - italiano (Italia)</option>
544  <option value="it-CH">Italian (Switzerland) - italiano (Svizzera)</option>
545  <option value="ja">Japanese - 日本語</option>
546  <option value="kn">Kannada - ಕನ್ನಡ</option>
547  <option value="kk">Kazakh - қазақ тілі</option>
548  <option value="km">Khmer - ខ្មែរ</option>
549  <option value="ko">Korean - 한국어</option>
550  <option value="ku">Kurdish - Kurdî</option>
551  <option value="ky">Kyrgyz - кыргызча</option>
552  <option value="lo">Lao - ລາວ</option>
553  <option value="la">Latin</option>
554  <option value="lv">Latvian - latviešu</option>
555  <option value="ln">Lingala - lingála</option>
556  <option value="lt">Lithuanian - lietuvių</option>
557  <option value="mk">Macedonian - македонски</option>
558  <option value="ms">Malay - Bahasa Melayu</option>
559  <option value="ml">Malayalam - മലയാളം</option>
560  <option value="mt">Maltese - Malti</option>
561  <option value="mr">Marathi - मराठी</option>
562  <option value="mn">Mongolian - монгол</option>
563  <option value="ne">Nepali - नेपाली</option>
564  <option value="no">Norwegian - norsk</option>
565  <option value="nb">Norwegian Bokmål - norsk bokmål</option>
566  <option value="nn">Norwegian Nynorsk - nynorsk</option>
567  <option value="oc">Occitan</option>
568  <option value="or">Oriya - ଓଡ଼ିଆ</option>
569  <option value="om">Oromo - Oromoo</option>
570  <option value="ps">Pashto - پښتو</option>
571  <option value="fa">Persian - فارسی</option>
572  <option value="pl">Polish - polski</option>
573  <option value="pt">Portuguese - português</option>
574  <option value="pt-BR">Portuguese (Brazil) - português (Brasil)</option>
575  <option value="pt-PT">Portuguese (Portugal) - português (Portugal)</option>
576  <option value="pa">Punjabi - ਪੰਜਾਬੀ</option>
577  <option value="qu">Quechua</option>
578  <option value="ro">Romanian - română</option>
579  <option value="mo">Romanian (Moldova) - română (Moldova)</option>
580  <option value="rm">Romansh - rumantsch</option>
581  <option value="ru">Russian - русский</option>
582  <option value="gd">Scottish Gaelic</option>
583  <option value="sr">Serbian - српски</option>
584  <option value="sh">Serbo-Croatian - Srpskohrvatski</option>
585  <option value="sn">Shona - chiShona</option>
586  <option value="sd">Sindhi</option>
587  <option value="si">Sinhala - සිංහල</option>
588  <option value="sk">Slovak - slovenčina</option>
589  <option value="sl">Slovenian - slovenščina</option>
590  <option value="so">Somali - Soomaali</option>
591  <option value="st">Southern Sotho</option>
592  <option value="es">Spanish - español</option>
593  <option value="es-AR">Spanish (Argentina) - español (Argentina)</option>
594  <option value="es-419">Spanish (Latin America) - español (Latinoamérica)</option>
595  <option value="es-MX">Spanish (Mexico) - español (México)</option>
596  <option value="es-ES">Spanish (Spain) - español (España)</option>
597  <option value="es-US">Spanish (United States) - español (Estados Unidos)</option>
598  <option value="su">Sundanese</option>
599  <option value="sw">Swahili - Kiswahili</option>
600  <option value="sv">Swedish - svenska</option>
601  <option value="tg">Tajik - тоҷикӣ</option>
602  <option value="ta">Tamil - தமிழ்</option>
603  <option value="tt">Tatar</option>
604  <option value="te">Telugu - తెలుగు</option>
605  <option value="th">Thai - ไทย</option>
606  <option value="ti">Tigrinya - ትግርኛ</option>
607  <option value="to">Tongan - lea fakatonga</option>
608  <option value="tr">Turkish - Türkçe</option>
609  <option value="tk">Turkmen</option>
610  <option value="tw">Twi</option>
611  <option value="uk">Ukrainian - українська</option>
612  <option value="ur">Urdu - اردو</option>
613  <option value="ug">Uyghur</option>
614  <option value="uz">Uzbek - o‘zbek</option>
615  <option value="vi">Vietnamese - Tiếng Việt</option>
616  <option value="wa">Walloon - wa</option>
617  <option value="cy">Welsh - Cymraeg</option>
618  <option value="fy">Western Frisian</option>
619  <option value="xh">Xhosa</option>
620  <option value="yi">Yiddish</option>
621  <option value="yo">Yoruba - Èdè Yorùbá</option>
622  <option value="zu">Zulu - isiZulu</option>';
623  }

◆ getClientLanguage()

YAWK\language::getClientLanguage ( )

get and return client language

Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Returns
string

Definition at line 204 of file language.php.

204  : string
205  {
206  // check if browser tells any accepted language
207  if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) || (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])))
208  { // format the string to eg: en-EN
209  $this->httpAcceptedLanguage = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 5);
210  $this->currentLanguageGlobal = substr($this->httpAcceptedLanguage, 0, 2);
212  }
213  else
214  { // var empty - cannot detect -
215  return false;
216  }
217  }

References YAWK\language\$httpAcceptedLanguage.

Referenced by YAWK\language\init().

◆ getCurrentLanguage()

YAWK\language::getCurrentLanguage (   $db,
  $referer 
)

returns the currently set language

Parameters
object$dbdatabase object
string$refererfrontend|backend from where it the call referred?
Returns
string

Definition at line 62 of file language.php.

62  : string
63  {
64 
65  if (isset($referer) && (is_string($referer)))
66  {
67  if ($referer == "frontend")
68  {
69  if ($this->currentLanguage = settings::getSetting($db, "frontendLanguage"))
70  {
71  $_SESSION['lang'] = $this->currentLanguage;
72  // return current language from db-settings// if not, try to set it - with error supressor to avoid notices if output started before
73  @setcookie('lang', $this->currentLanguage, time() + (60 * 60 * 24 * 1460));
75  }
76  else
77  { // failed to get language
78  $this->currentLanguage = "en-EN"; // default: en-EN
79  $_SESSION['lang'] = $this->currentLanguage;
80  // return default value (en-EN)
82  }
83  }
84  else if ($referer == "backend")
85  {
86 
87  if ($this->currentLanguage = settings::getSetting($db, "backendLanguage"))
88  {
89  $_SESSION['lang'] = $this->currentLanguage;
90  // return current language from db-settings// if not, try to set it - with error supressor to avoid notices if output started before
91  @setcookie('lang', $this->currentLanguage, time() + (60 * 60 * 24 * 1460));
93  }
94  else
95  { // failed to get language
96  $this->currentLanguage = "en-EN"; // default: en-EN
97  $_SESSION['lang'] = $this->currentLanguage;
98  // return default value (en-EN)
100  }
101  }
102  else
103  {
104  if ($this->currentLanguage = settings::getSetting($db, "backendLanguage"))
105  {
106  $_SESSION['lang'] = $this->currentLanguage;
107  // return current language from db-settings// if not, try to set it - with error supressor to avoid notices if output started before
108  @setcookie('lang', $this->currentLanguage, time() + (60 * 60 * 24 * 1460));
109  return $this->currentLanguage;
110  }
111  else
112  { // failed to get language
113  $this->currentLanguage = "en-EN"; // default: en-EN
114  $_SESSION['lang'] = $this->currentLanguage;
115  // return default value (en-EN)
116  return $this->currentLanguage;
117  }
118  }
119  }
120  else
121  {
122  if ($this->currentLanguage = settings::getSetting($db, "backendLanguage"))
123  {
124  $_SESSION['lang'] = $this->currentLanguage;
125  // return current language from db-settings// if not, try to set it - with error supressor to avoid notices if output started before
126  @setcookie('lang', $this->currentLanguage, time() + (60 * 60 * 24 * 1460));
127  return $this->currentLanguage;
128  }
129  else
130  { // failed to get language
131  $this->currentLanguage = "en-EN"; // default: en-EN
132  $_SESSION['lang'] = $this->currentLanguage;
133  // return default value (en-EN)
134  return $this->currentLanguage;
135  }
136  }
137  }
static getSetting($db, $property)
Get and return value for property from settings database.
Definition: settings.php:470

References YAWK\language\$currentLanguage, $db, and YAWK\settings\getSetting().

Referenced by YAWK\language\init().

◆ getCurrentLanguageStatic()

static YAWK\language::getCurrentLanguageStatic ( )
static

returns the currently set backend language, but is static callable

Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Returns
string

Definition at line 146 of file language.php.

147  {
148  $currentLanguage = '';
149  // check if a GET param is set
150  if (isset($_GET['lang']) && (!empty($_GET['lang'])))
151  {
152  $currentLanguage = $_GET['lang']; // set GET param as current language
153  // register and overwrite session var
154  $_SESSION['lang'] = $currentLanguage;
155  // and check if cookie is set
156  if (empty($_COOKIE['lang']))
157  { // if not, try to set it - with error suppressor to avoid notices if output started before
158  @setcookie('lang', $currentLanguage, time() + (60 * 60 * 24 * 1460));
159  }
160  /* language set, cookie set */
161  return $currentLanguage;
162  }
163  else
164  {
165  // GET param not set, check if there is a $_SESSION[lang]
166  if (isset($_SESSION['lang']) && (!empty($_SESSION['lang'])))
167  {
168  // session var is set
169  return $_SESSION['lang'];
170  }
171  // SESSION param not set, check if there is a $_COOKIE[lang]
172  elseif (isset($_COOKIE['lang']) && (!empty($_COOKIE['lang'])))
173  {
174  // cookie var is set
175  return $_COOKIE['lang'];
176  }
177  else
178  {
179  // get language setting from database
180  if (!isset($db))
181  { // create new db object
182  require_once '../system/classes/db.php';
183  require_once '../system/classes/settings.php';
184  $db = new db();
185  }
186  // get backend language setting and save string eg. (en-EN) in $this->current
187  if (!($currentLanguage = (settings::getSetting($db, "backendLanguage")) === true)) { // failed to get backend language
188  $currentLanguage = "en-EN"; // default: en-EN
189  // return default value (en-EN)
190  }
191  return $currentLanguage;
192  }
193  }
194  }
print $_GET['id']
Definition: page-edit.php:357

References $_GET, YAWK\language\$currentLanguage, $db, and YAWK\settings\getSetting().

Referenced by YAWK\WIDGETS\LOGINBOX\LOGIN\loginbox\includeJS(), YAWK\WIDGETS\NEWSLETTER\SUBSCRIBE\newsletter\includeJS(), YAWK\language\inject(), and YAWK\sys\time_ago().

◆ getPathToLanguageFile()

YAWK\language::getPathToLanguageFile ( )

Returns the path to the language file.

Definition at line 323 of file language.php.

324  {
325  // check if call comes from frontend or backend
326  if(stristr($_SERVER['PHP_SELF'], '/admin/') == TRUE)
327  {
328  // call seem to come from BACKEND
329  // check if directory is reachable
330  if (is_dir("language/"))
331  {
332  // set path to backend
333  $this->pathToFile = "language/";
334  }
335  elseif (is_dir("admin/language/"))
336  {
337  $this->pathToFile = "admin/language";
338  }
339  // call seems to come from admin/js/ folder (probably a class called by ajax in /system/classes/*
340  elseif (is_dir("../language/"))
341  {
342  $base_dir = __DIR__;
343  $base_dir = substr($base_dir, 0, -15); // remove last 15 chars
344  $this->pathToFile = $base_dir."/admin/language/";
345  }
346  else
347  {
348  '';
349  }
350  }
351 
352  // if setup is running
353  else if (isset($_SESSION['SETUP']) && ($_SESSION['SETUP'] == TRUE))
354  { // load backend language files
355  $this->pathToFile = "admin/language/";
356  }
357 
358  // in any other case load frontend language
359  else
360  { // set path to FRONTEND
361  if (is_dir("system/language/"))
362  { // set frontend language path
363  $this->pathToFile = "system/language/";
364  }
365  // if frontend language files are not reachable, check if backend language files exist
366  else if (is_dir("admin/language"))
367  { // load backend files instead
368  $this->pathToFile = "admin/language/";
369  }
370  // if frontend language files are not reachable, check if backend language files exist
371  else if (is_dir("../../../language"))
372  { // load backend files instead
373  $this->pathToFile = "../../../language/";
374  }
375  else
376  { // no language files found (even no backend files)
377  die ("ERROR: Unable to load language files. Several conditions failed - files are missing or corrupt. Please inform the page administrator about this concern.");
378  }
379  }
380  return $this->pathToFile;
381  }
die
Definition: block-user.php:27

References YAWK\language\$pathToFile, and die.

Referenced by YAWK\language\setLanguage().

◆ getSupportedLanguages()

YAWK\language::getSupportedLanguages ( )

sets object supportedLanguages as array including all supported languages

Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Returns
bool

Definition at line 226 of file language.php.

226  : bool
227  {
228  // walk /admin/language folder and get all language files into an array
229  require_once ('system/classes/filemanager.php');
230  $languageFiles = filemanager::getFilesFromFolderToArray('admin/language');
231  foreach ($languageFiles AS $file)
232  {
233  if ($file != ".htaccess")
234  {
235  $globalLanguageTag = substr($file, 5, -7);
236  $this->supportedLanguagesGlobal[] = $globalLanguageTag;
237  $localLanguageTag = substr($file, 5, -4);
238  $this->supportedLanguages[] = $localLanguageTag;
239  // $this->supportedLanguages[] = $globalLanguageTag;
240  }
241  }
242  if (is_array($this->supportedLanguagesGlobal) && (is_array($this->supportedLanguages)))
243  {
244  return true;
245  }
246  else
247  {
248  return false;
249  }
250  }
static getFilesFromFolderToArray($folder)
returns an array containing only files from folder (no subfolders)

References YAWK\filemanager\getFilesFromFolderToArray().

Referenced by YAWK\language\isSupported().

◆ init()

YAWK\language::init (   $db,
  $referer 
)

initialize and return current language

Returns
array|bool

Definition at line 46 of file language.php.

47  {
48  // set current language
49  $this->httpAcceptedLanguage = $this->getClientLanguage();
50  $this->currentFrontendLanguage = settings::getSetting($db, "frontendLanguage");
51  $this->currentLanguage = $this->getCurrentLanguage($db, $referer);
52  return $this->setLanguage($this->currentLanguage);
53  }
getClientLanguage()
get and return client language
Definition: language.php:204
setLanguage(string $currentLanguage)
set client language and parse corresponding ini file to an array called $lang
Definition: language.php:388
getCurrentLanguage($db, $referer)
returns the currently set language
Definition: language.php:62

References $db, YAWK\language\getClientLanguage(), YAWK\language\getCurrentLanguage(), YAWK\settings\getSetting(), and YAWK\language\setLanguage().

◆ inject()

static YAWK\language::inject ( array  $lang,
string  $pathToFile 
)
static

allow plugins to inject language tags to $lang array

Parameters
array$langthe language data array
string$pathToFileabsolute path to the injectable language file
Returns
array $lang returns pushed language array

Definition at line 439 of file language.php.

439  : array
440  {
441  // check if language is saved in session or cookie to prevent unnecessary db actions
442  if (isset($_SESSION['lang']))
443  { // set from session setting
444  $currentLanguage = $_SESSION['lang'];
445  }
446  elseif (isset($_COOKIE['lang']))
447  { // set from cookie setting
448  $currentLanguage = $_COOKIE['lang'];
449  }
450  elseif (isset($_GET['lang']))
451  { // set from cookie setting
452  $currentLanguage = $_GET['lang'];
453  }
454  else
455  { // get current language from db
457  if (isset($currentLanguage) && (!empty($currentLanguage)))
458  { // set session var to save database resources
459  $_SESSION['lang'] = $currentLanguage;
460  }
461  }
462 
463  // get injectable tags from additional language file
464  $additionalTags = parse_ini_file("$pathToFile"."$currentLanguage".".ini");
465  // add every tag, once per row
466  foreach ($additionalTags AS $tag => $value)
467  { // add data to $lang array
468  $lang[$tag] = $value;
469  }
470  // fin -
471  return $lang;
472  } /* end setLanguage */
static getCurrentLanguageStatic()
returns the currently set backend language, but is static callable
Definition: language.php:146
$value

References $_GET, YAWK\language\$currentLanguage, YAWK\language\$lang, $value, and YAWK\language\getCurrentLanguageStatic().

◆ isSupported()

YAWK\language::isSupported ( string  $currentLanguage)

Check if a language is supported. This functions expect currentLanguage string in format "en-EN" or "en".

Parameters
string$currentLanguagelanguage in format: en-EN or en
Returns
bool @license https://opensource.org/licenses/MIT

Definition at line 259 of file language.php.

259  : bool
260  {
261  // create arrays with supported languages, one in format "en", the other one "en-EN"
262  $this->getSupportedLanguages();
263 
264  // check if language is set and not empty
265  if (isset($currentLanguage) && (!empty($currentLanguage)))
266  {
267  // if language is submitted as global language tag (short, like: en instead of en-EN)
268  if (strlen($currentLanguage) <= 2)
269  {
270  // check if supportedLanguages match with language
271  if (in_array($currentLanguage, $this->supportedLanguagesGlobal))
272  {
273  // language is supported
274  // $language->setLanguage($language->currentLanguageGlobal); // set language
275  return true;
276  }
277  else
278  {
279  // detected language is not supported, set en-EN as default
280  return false;
281  }
282  } // end global language tag (en)
283  else
284  { // check supportedLanguagesLocal match with detected user language
285  if (in_array($currentLanguage, $this->supportedLanguages))
286  { // language supported
287  return true;
288  }
289  else
290  { // language not supported
291  return false;
292  }
293  }
294  }
295  else
296  { // language is not set
297  return false;
298  }
299  }
getSupportedLanguages()
sets object supportedLanguages as array including all supported languages
Definition: language.php:226

References YAWK\language\$currentLanguage, and YAWK\language\getSupportedLanguages().

◆ setDefault()

YAWK\language::setDefault ( string  $defaultLanguage)

Set a language as default and load (set) it current language.

Parameters
string$defaultLanguagelanguage in format: en-EN or en

Definition at line 307 of file language.php.

308  {
309  if ((!empty($defaultLanguage)))
310  {
311  // set default language
312  $this->currentLanguage = $defaultLanguage;
314  }
315  }

References YAWK\language\$defaultLanguage, and YAWK\language\setLanguage().

◆ setLanguage()

YAWK\language::setLanguage ( string  $currentLanguage)

set client language and parse corresponding ini file to an array called $lang

Parameters
string$currentLanguagethe current language as string (e.g. en-US)
Returns
array|bool $lang returns a language array

Definition at line 388 of file language.php.

389  {
390  $this->pathToFile = $this->getPathToLanguageFile();
391 
392  // short language identify string global (just 2 chars) sent
393  if (strlen($currentLanguage) == 2)
394  { // build a proper currentLanguage string
395  $global = $currentLanguage;
396  $local = strtoupper($currentLanguage);
397  $currentLanguage = "$global-$local";
398  $this->currentLanguage = $currentLanguage;
399  }
400  // if language file exists...
401  if (is_file("$this->pathToFile"."lang-"."$currentLanguage".".ini"))
402  { // parse language file into array
403  if ($this->lang = parse_ini_file("$this->pathToFile"."lang-"."$currentLanguage".".ini"))
404  { // file loaded, return language array
405  return $this->lang;
406  }
407  else
408  { // file could not be parsed into array - abort with error
409  die ("could not load language file: $this->pathToFile"."lang-"."$currentLanguage".".ini");
410  }
411  }
412  // language file does not exist - check if an en-EN file exists...
413  elseif (is_file("$this->pathToFile"."lang-en-EN.ini"))
414  { // parse language file into array
415  if ($this->lang = parse_ini_file("$this->pathToFile"."lang-en-EN.ini"))
416  { // file loaded, return language array
417  return $this->lang;
418  }
419  else
420  { // file could not be parsed into array - abort with error
421  die ("ERROR: Could not load language file: $this->pathToFile"."lang-en-EN.ini");
422  }
423  }
424  else
425  { // language file not found
426  // english (default) language file not found
427  // abort with error
428  die ("CRITICAL ERROR: No language file found. It should be there, but it isn't. This is strange. Please check $this->pathToFile and install a language file.");
429  }
430  } /* end setLanguage */
getPathToLanguageFile()
Returns the path to the language file.
Definition: language.php:323

References YAWK\language\$currentLanguage, YAWK\language\$lang, die, and YAWK\language\getPathToLanguageFile().

Referenced by YAWK\language\init(), and YAWK\language\setDefault().

Member Data Documentation

◆ $currentFrontendLanguage

YAWK\language::$currentFrontendLanguage
  • Parameters
    string$currentLanguagecurrent setted language in format: en-EN

Definition at line 25 of file language.php.

◆ $currentLanguage

YAWK\language::$currentLanguage
  • Parameters
    string$currentLanguagecurrent setted language in format: en-EN

Definition at line 23 of file language.php.

Referenced by YAWK\language\getCurrentLanguage(), YAWK\language\getCurrentLanguageStatic(), YAWK\language\inject(), YAWK\language\isSupported(), and YAWK\language\setLanguage().

◆ $currentLanguageGlobal

YAWK\language::$currentLanguageGlobal
  • Parameters
    string$currentLanguageGlobalcurrent setted language in format: en

Definition at line 27 of file language.php.

◆ $defaultLanguage

YAWK\language::$defaultLanguage
  • Parameters
    string$defaultLanguagedefault language if no supported language can be detected

Definition at line 21 of file language.php.

Referenced by YAWK\language\setDefault().

◆ $detectedLanguage

YAWK\language::$detectedLanguage
  • Parameters
    string$detectedLanguagecurrent detected language in format: en-EN

Definition at line 29 of file language.php.

◆ $detectedLanguageGlobal

YAWK\language::$detectedLanguageGlobal
  • Parameters
    string$detectedLanguageGlobalcurrent detected language in format: en

Definition at line 31 of file language.php.

◆ $httpAcceptedLanguage

YAWK\language::$httpAcceptedLanguage
  • Parameters
    string$httpAcceptedLanguagecurrent $_SERVER['HTTP_ACCEPTED_LANGUAGE'] in format: en-EN

Definition at line 33 of file language.php.

Referenced by YAWK\language\getClientLanguage().

◆ $lang

YAWK\language::$lang
  • Parameters
    array$langlanguage array

Definition at line 19 of file language.php.

Referenced by YAWK\language\inject(), and YAWK\language\setLanguage().

◆ $pathToFile

YAWK\language::$pathToFile
  • Parameters
    string$pathToFilethe path to the language file

Definition at line 35 of file language.php.

Referenced by YAWK\language\getPathToLanguageFile().

◆ $supportedLanguages

YAWK\language::$supportedLanguages
  • Parameters
    array$supportedLanguagesarray that contains all supported languages, but the full tag eg. (en-EN)

Definition at line 39 of file language.php.

◆ $supportedLanguagesGlobal

YAWK\language::$supportedLanguagesGlobal
  • Parameters
    array$supportedLanguagesGlobalarray that contains all supported languages, shortened to the first 2 chars eg. (en)

Definition at line 37 of file language.php.


The documentation for this class was generated from the following file: