xref: /web-php/include/languages.inc (revision 15f35ce9)
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];
36
37$ACTIVE_ONLINE_LANGUAGES = array_diff($LANGUAGES, $INACTIVE_ONLINE_LANGUAGES);
38
39// Convert between language codes back and forth
40// [We use non-standard languages codes and so conversion
41// is needed when communicating with the outside world]
42function language_convert(string $langcode): string
43{
44    global $LANGUAGES;
45    switch ($langcode) {
46        case 'zh_cn': return 'zh';
47        default:
48            // Fallback on english if we got something wacky
49            return array_key_exists($langcode, $LANGUAGES) ? $langcode : 'en';
50    }
51}
52