Issues (27)

Labels
Severity
1
<?php
2
3
// Copyright (C) 2014-2023 Universitätsbibliothek Mannheim
4
// See file LICENSE for license details.
5
6
require_once 'php-gettext/gettext.inc';
7
8
// The default translations are in locale/en_US.UTF-8/LC_MESSAGES/palma.mo.
9
$locale = '';
10
if (isset($_REQUEST['lang'])) {
11
  // User requested language by URL parameter.
12
  $locale = $_REQUEST['lang'];
13
  $_SESSION['lang'] = $locale;
14
} elseif (isset($_SESSION['lang'])) {
15
  // Get language from session data.
16
  $locale = $_SESSION['lang'];
17
} elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
18
  // Get language from browser settings.
19
  $locale = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
20
}
21
switch (substr($locale, 0, 2)) {
22
  case 'al':
23
      // Albanian.
24
      $locale = 'sq_AL.UTF-8';
25
      break;
26
  case 'ar':
27
      // Arabic.
28
      $locale = 'ar.UTF-8';
29
      break;
30
  case 'de':
31
      // German.
32
      $locale = 'de_DE.UTF-8';
33
      break;
34
  case 'el':
35
      // Greek.
36
      $locale = 'el_GR.UTF-8';
37
      break;
38
  case 'en':
39
      // English.
40
      $locale = 'en_US.UTF-8';
41
      break;
42
  case 'es':
43
      // Spanish.
44
      $locale = 'es_ES.UTF-8';
45
      break;
46
  case 'fr':
47
      // French.
48
      $locale = 'fr_FR.UTF-8';
49
      break;
50
  case 'hi':
51
      // Hindi.
52
      $locale = 'hi_IN.UTF-8';
53
      break;
54
  case 'it':
55
      // Italian.
56
      $locale = 'it_IT.UTF-8';
57
      break;
58
  case 'ja':
59
      // Japanese.
60
      $locale = 'ja.UTF-8';
61
      break;
62
  case 'kg':
63
      // Kyrgyz.
64
      $locale = 'kg_KG.UTF-8';
65
      break;
66
  case 'lv':
67
      // Latvian.
68
      $locale = 'lv_LV.UTF-8';
69
      break;
70
  case 'ru':
71
      // Russian.
72
      $locale = 'ru_RU.UTF-8';
73
      break;
74
  case 'ur':
75
      // Urdu.
76
      $locale = 'ur_PK.UTF-8';
77
      break;
78
  case 'zh':
79
      // Chinese.
80
      $locale = 'zh_CN.UTF-8';
81
      break;
82
  default:
83
      $locale = 'en_US.UTF-8';
84
      break;
85
}
86
87
//~ error_log("setlocale $locale");
88
putenv("LANG=$locale");
89
_setlocale(LC_MESSAGES, $locale);
0 ignored issues
show
The function _setlocale was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

89
/** @scrutinizer ignore-call */ 
90
_setlocale(LC_MESSAGES, $locale);
Loading history...
90
_bindtextdomain('palma', 'locale');
0 ignored issues
show
The function _bindtextdomain was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

90
/** @scrutinizer ignore-call */ 
91
_bindtextdomain('palma', 'locale');
Loading history...
91
_bind_textdomain_codeset('palma', 'UTF-8');
0 ignored issues
show
The function _bind_textdomain_codeset was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

91
/** @scrutinizer ignore-call */ 
92
_bind_textdomain_codeset('palma', 'UTF-8');
Loading history...
92
_textdomain('palma');
0 ignored issues
show
The function _textdomain was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

92
/** @scrutinizer ignore-call */ 
93
_textdomain('palma');
Loading history...
93