UB-Mannheim /
PalMA
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | // Copyright (C) 2014-2016 Universitätsbibliothek Mannheim |
||
| 4 | // See file LICENSE for license details. |
||
| 5 | |||
| 6 | // Test whether the script was called directly (used for unit test). |
||
| 7 | if (!isset($unittest)) { |
||
| 8 | $unittest = array(); |
||
| 9 | } |
||
| 10 | $unittest[__FILE__] = (sizeof(get_included_files()) == 1); |
||
| 11 | |||
| 12 | require_once('php-gettext/gettext.inc'); |
||
| 13 | |||
| 14 | // The default translations are in locale/en_US.UTF-8/LC_MESSAGES/palma.mo. |
||
| 15 | $locale = ''; |
||
| 16 | if (isset($_REQUEST['lang'])) { |
||
| 17 | // User requested language by URL parameter. |
||
| 18 | $locale = $_REQUEST['lang']; |
||
| 19 | $_SESSION['lang'] = $locale; |
||
| 20 | } else if (isset($_SESSION['lang'])) { |
||
| 21 | // Get language from session data. |
||
| 22 | $locale = $_SESSION['lang']; |
||
| 23 | } else if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { |
||
| 24 | // Get language from browser settings. |
||
| 25 | $locale = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']); |
||
| 26 | } |
||
| 27 | switch (substr($locale, 0, 2)) { |
||
| 28 | case 'al': |
||
| 29 | // Albanian. |
||
| 30 | $locale = 'al_AL.UTF-8'; |
||
| 31 | break; |
||
| 32 | case 'ar': |
||
| 33 | // Arabic. |
||
| 34 | $locale = 'ar.UTF-8'; |
||
| 35 | break; |
||
| 36 | case 'de': |
||
| 37 | // German. |
||
| 38 | $locale = 'de_DE.UTF-8'; |
||
| 39 | break; |
||
| 40 | case 'en': |
||
| 41 | // English. |
||
| 42 | $locale = 'en_US.UTF-8'; |
||
| 43 | break; |
||
| 44 | case 'es': |
||
| 45 | // Spanish. |
||
| 46 | $locale = 'es_ES.UTF-8'; |
||
| 47 | break; |
||
| 48 | case 'fr': |
||
| 49 | // French. |
||
| 50 | $locale = 'fr_FR.UTF-8'; |
||
| 51 | break; |
||
| 52 | case 'it': |
||
| 53 | // Italian. |
||
| 54 | $locale = 'it_IT.UTF-8'; |
||
| 55 | break; |
||
| 56 | case 'lv': |
||
| 57 | // Latvian. |
||
| 58 | $locale = 'lv_LV.UTF-8'; |
||
| 59 | break; |
||
| 60 | case 'ru': |
||
| 61 | // Russian. |
||
| 62 | $locale = 'ru_RU.UTF-8'; |
||
| 63 | break; |
||
| 64 | case 'ur': |
||
| 65 | // Urdu. |
||
| 66 | $locale = 'ur_PK.UTF-8'; |
||
| 67 | break; |
||
| 68 | case 'zh': |
||
| 69 | // Chinese. |
||
| 70 | $locale = 'zh_CN.UTF-8'; |
||
| 71 | break; |
||
| 72 | default: |
||
| 73 | $locale = 'en_US.UTF-8'; |
||
| 74 | break; |
||
| 75 | } |
||
| 76 | //~ error_log("setlocale $locale"); |
||
| 77 | putenv("LANG=$locale"); |
||
| 78 | _setlocale(LC_MESSAGES, $locale); |
||
| 79 | _bindtextdomain('palma', 'locale'); |
||
| 80 | _bind_textdomain_codeset('palma', 'UTF-8'); |
||
| 81 | _textdomain('palma'); |
||
| 82 | |||
| 83 | if ($unittest[__FILE__]) { |
||
| 84 | |||
| 85 | function testlocale($locale = false) |
||
| 86 | { |
||
| 87 | if ($locale) { |
||
| 88 | _setlocale(LC_MESSAGES, $locale); |
||
| 89 | } |
||
| 90 | error_log(sprintf('%-12s ', ($locale ? $locale : 'default') . ':') . __('Screen section')); |
||
| 91 | } |
||
| 92 | |||
| 93 | // Run unit test. |
||
| 94 | |||
| 95 | if (locale_emulation()) { |
||
| 96 | print "locale '$locale' is not supported on your system, using custom gettext implementation.\n"; |
||
| 97 | } |
||
| 98 | else { |
||
| 99 | print "locale '$locale' is supported on your system, using native gettext implementation.\n"; |
||
| 100 | } |
||
| 101 | |||
| 102 | testlocale(); |
||
| 103 | testlocale('al_AL.UTF-8'); |
||
| 104 | testlocale('ar.UTF-8'); |
||
| 105 | testlocale('de_DE.UTF-8'); |
||
| 106 | testlocale('en_US.UTF-8'); |
||
| 107 | testlocale('es_ES.UTF-8'); |
||
| 108 | testlocale('fr_FR.UTF-8'); |
||
|
0 ignored issues
–
show
|
|||
| 109 | testlocale('it_IT.UTF-8'); |
||
| 110 | testlocale('lv_LV.UTF-8'); |
||
| 111 | testlocale('ru_RU.UTF-8'); |
||
| 112 | testlocale('ur_PK.UTF-8'); |
||
| 113 | testlocale('zh_CN.UTF-8'); |
||
| 114 | } |
||
| 115 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: