1<?php 2 3/* 4 This is a list of all manual languages hosted 5 within PHP Git repositories (https://github.com/php/doc-{lang}) 6*/ 7$LANGUAGES = [ 8 'en' => 'English', 9 'de' => 'German', 10 'es' => 'Spanish', 11 'fr' => 'French', 12 'it' => 'Italian', 13 'ja' => 'Japanese', 14 'pl' => 'Polish', 15 'pt_BR' => 'Brazilian Portuguese', 16 'ro' => 'Romanian', 17 'ru' => 'Russian', 18 'tr' => 'Turkish', 19 'uk' => 'Ukrainian', 20 'zh' => 'Chinese (Simplified)', 21]; 22 23/* 24 The following languages are inactive, which means they will not: 25 - Show up via the language select box at php.net 26 - Be selectable via my.php 27 - Accept redirections to the translation, despite ACCEPT_LANGUAGE 28 - Be listed at php.net/docs or php.net/download-docs 29 However, these languages are available on the doc dev server: 30 - http://docs.php.net/ 31*/ 32$INACTIVE_ONLINE_LANGUAGES = [ 33 'pl' => 'Polish', 34 'ro' => 'Romanian', 35 'uk' => 'Ukrainian', 36]; 37 38$ACTIVE_ONLINE_LANGUAGES = array_diff($LANGUAGES, $INACTIVE_ONLINE_LANGUAGES); 39 40// Convert between language codes back and forth 41// [We use non-standard languages codes and so conversion 42// is needed when communicating with the outside world] 43function language_convert(string $langcode): string 44{ 45 global $LANGUAGES; 46 switch ($langcode) { 47 case 'zh_cn': return 'zh'; 48 default: 49 // Fallback on english if we got something wacky 50 return array_key_exists($langcode, $LANGUAGES) ? $langcode : 'en'; 51 } 52} 53