Commit 56f4362a authored by alexpott's avatar alexpott

Issue #1845034 by RobLoach, sandykadam, nick_schuch, cam8001, Gábor Hojtsy:...

Issue #1845034 by RobLoach, sandykadam, nick_schuch, cam8001, Gábor Hojtsy: Convert standard.inc to Drupal\Core\Language.
parent 7485f62b
......@@ -8,6 +8,7 @@
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Install\TaskException;
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageManager;
use Drupal\Core\StringTranslation\Translator\FileTranslation;
use Symfony\Component\DependencyInjection\ContainerBuilder;
......@@ -1435,8 +1436,6 @@ function install_file_translation_service() {
* language cannot be chosen automatically.
*/
function install_select_language(&$install_state) {
include_once __DIR__ . '/standard.inc';
// Find all available translation files.
$files = install_find_translations();
$install_state['translations'] += $files;
......@@ -1448,7 +1447,7 @@ function install_select_language(&$install_state) {
// When files from the translation directory are used, we only accept
// languages for which a file is available.
if (!empty($_POST['langcode'])) {
$standard_languages = standard_language_list();
$standard_languages = LanguageManager::getStandardLanguageList();
$langcode = $_POST['langcode'];
if ($langcode == 'en' || isset($files[$langcode]) || isset($standard_languages[$langcode])) {
$install_state['parameters']['langcode'] = $langcode;
......@@ -1494,11 +1493,10 @@ function install_select_language(&$install_state) {
* @ingroup forms
*/
function install_select_language_form($form, &$form_state, $files = array()) {
include_once __DIR__ . '/standard.inc';
include_once __DIR__ . '/../modules/language/language.module';
include_once __DIR__ . '/../modules/language/language.negotiation.inc';
$standard_languages = standard_language_list();
$standard_languages = LanguageManager::getStandardLanguageList();
$select_options = array();
$browser_options = array();
......@@ -1775,10 +1773,9 @@ function install_profile_modules(&$install_state) {
*/
function install_import_translations(&$install_state) {
include_once __DIR__ . '/../modules/locale/locale.bulk.inc';
include_once __DIR__ . '/standard.inc';
$langcode = $install_state['parameters']['langcode'];
$standard_languages = standard_language_list();
$standard_languages = LanguageManager::getStandardLanguageList();
if (!isset($standard_languages[$langcode])) {
// Drupal does not know about this language, so we prefill its values with
// our best guess. The user will be able to edit afterwards.
......@@ -1998,7 +1995,6 @@ function _install_profile_modules_finished($success, $results, $operations) {
* Checks installation requirements and reports any errors.
*/
function install_check_translations($install_state) {
include_once __DIR__ . '/standard.inc';
$requirements = array();
$readable = FALSE;
......@@ -2035,7 +2031,7 @@ function install_check_translations($install_state) {
$server_url = $elements['scheme'] . '://' . $elements['host'];
// Build the language name for display.
$languages = standard_language_list();
$languages = LanguageManager::getStandardLanguageList();
$language = isset($languages[$langcode]) ? $languages[$langcode][0] : $langcode;
// Check if the desirered translation file is available and if the translation
......
......@@ -283,116 +283,3 @@ function standard_country_list() {
return $countries;
}
/**
* Some common languages with their English and native names.
*
* Language codes are defined by the W3C language tags document for
* interoperability. Language codes typically have a language and optionally,
* a script or regional variant name. See
* http://www.w3.org/International/articles/language-tags/ for more information.
*
* This list is based on languages available from localize.drupal.org. See
* http://localize.drupal.org/issues for information on how to add languages
* there.
*
* The "Left-to-right marker" comments and the enclosed UTF-8 markers are to
* make otherwise strange looking PHP syntax natural (to not be displayed in
* right to left). See http://drupal.org/node/128866#comment-528929.
*
* @return array
* An array of language code to language name information.
* Language name information itself is an array of English and native names.
*/
function standard_language_list() {
return array(
'af' => array('Afrikaans', 'Afrikaans'),
'am' => array('Amharic', 'አማርኛ'),
'ar' => array('Arabic', /* Left-to-right marker "‭" */ 'العربية', Language::DIRECTION_RTL),
'ast' => array('Asturian', 'Asturianu'),
'az' => array('Azerbaijani', 'Azərbaycanca'),
'be' => array('Belarusian', 'Беларуская'),
'bg' => array('Bulgarian', 'Български'),
'bn' => array('Bengali', 'বাংলা'),
'bo' => array('Tibetan', 'བོད་སྐད་'),
'bs' => array('Bosnian', 'Bosanski'),
'ca' => array('Catalan', 'Català'),
'cs' => array('Czech', 'Čeština'),
'cy' => array('Welsh', 'Cymraeg'),
'da' => array('Danish', 'Dansk'),
'de' => array('German', 'Deutsch'),
'dz' => array('Dzongkha', 'རྫོང་ཁ'),
'el' => array('Greek', 'Ελληνικά'),
'en' => array('English', 'English'),
'eo' => array('Esperanto', 'Esperanto'),
'es' => array('Spanish', 'Español'),
'et' => array('Estonian', 'Eesti'),
'eu' => array('Basque', 'Euskera'),
'fa' => array('Persian, Farsi', /* Left-to-right marker "‭" */ 'فارسی', Language::DIRECTION_RTL),
'fi' => array('Finnish', 'Suomi'),
'fil' => array('Filipino', 'Filipino'),
'fo' => array('Faeroese', 'Føroyskt'),
'fr' => array('French', 'Français'),
'gd' => array('Scots Gaelic', 'Gàidhlig'),
'gl' => array('Galician', 'Galego'),
'gsw-berne' => array('Swiss German', 'Schwyzerdütsch'),
'gu' => array('Gujarati', 'ગુજરાતી'),
'he' => array('Hebrew', /* Left-to-right marker "‭" */ 'עברית', Language::DIRECTION_RTL),
'hi' => array('Hindi', 'हिन्दी'),
'hr' => array('Croatian', 'Hrvatski'),
'ht' => array('Haitian Creole', 'Kreyòl ayisyen'),
'hu' => array('Hungarian', 'Magyar'),
'id' => array('Indonesian', 'Bahasa Indonesia'),
'is' => array('Icelandic', 'Íslenska'),
'it' => array('Italian', 'Italiano'),
'ja' => array('Japanese', '日本語'),
'jv' => array('Javanese', 'Basa Java'),
'ka' => array('Georgian', 'ქართული ენა'),
'kk' => array('Kazakh', 'Қазақ'),
'kn' => array('Kannada', 'ಕನ್ನಡ'),
'ko' => array('Korean', '한국어'),
'ku' => array('Kurdish', 'Kurdî'),
'ky' => array('Kyrgyz', 'Кыргызча'),
'lo' => array('Lao', 'ພາສາລາວ'),
'lt' => array('Lithuanian', 'Lietuvių'),
'lv' => array('Latvian', 'Latviešu'),
'mg' => array('Malagasy', 'Malagasy'),
'mk' => array('Macedonian', 'Македонски'),
'ml' => array('Malayalam', 'മലയാളം'),
'mn' => array('Mongolian', 'монгол'),
'mr' => array('Marathi', 'मराठी'),
'my' => array('Burmese', 'ဗမာစကား'),
'ne' => array('Nepali', 'नेपाली'),
'nl' => array('Dutch', 'Nederlands'),
'nb' => array('Norwegian Bokmål', 'Bokmål'),
'nn' => array('Norwegian Nynorsk', 'Nynorsk'),
'oc' => array('Occitan', 'Occitan'),
'pa' => array('Punjabi', 'ਪੰਜਾਬੀ'),
'pl' => array('Polish', 'Polski'),
'pt-pt' => array('Portuguese, Portugal', 'Português, Portugal'),
'pt-br' => array('Portuguese, Brazil', 'Português, Brasil'),
'ro' => array('Romanian', 'Română'),
'ru' => array('Russian', 'Русский'),
'sco' => array('Scots', 'Scots'),
'se' => array('Northern Sami', 'Sámi'),
'si' => array('Sinhala', 'සිංහල'),
'sk' => array('Slovak', 'Slovenčina'),
'sl' => array('Slovenian', 'Slovenščina'),
'sq' => array('Albanian', 'Shqip'),
'sr' => array('Serbian', 'Српски'),
'sv' => array('Swedish', 'Svenska'),
'ta' => array('Tamil', 'தமிழ்'),
'ta-lk' => array('Tamil, Sri Lanka', 'தமிழ், இலங்கை'),
'te' => array('Telugu', 'తెలుగు'),
'th' => array('Thai', 'ภาษาไทย'),
'tr' => array('Turkish', 'Türkçe'),
'tyv' => array('Tuvan', 'Тыва дыл'),
'ug' => array('Uyghur', 'Уйғур'),
'uk' => array('Ukrainian', 'Українська'),
'ur' => array('Urdu', /* Left-to-right marker "‭" */ 'اردو', Language::DIRECTION_RTL),
'vi' => array('Vietnamese', 'Tiếng Việt'),
'xx-lolspeak' => array('Lolspeak', 'Lolspeak'),
'zh-hans' => array('Chinese, Simplified', '简体中文'),
'zh-hant' => array('Chinese, Traditional', '繁體中文'),
);
}
......@@ -123,8 +123,7 @@ public function __construct(array $options = array()) {
}
// If some options were not set, set sane defaults of a predefined language.
if (!isset($options['name']) || !isset($options['direction'])) {
include_once DRUPAL_ROOT . '/core/includes/standard.inc';
$predefined = standard_language_list();
$predefined = LanguageManager::getStandardLanguageList();
if (isset($predefined[$this->langcode])) {
if (!isset($options['name'])) {
$this->name = $predefined[$this->langcode][0];
......
......@@ -165,4 +165,117 @@ protected function getLanguageDefault() {
return new Language($default_info + array('default' => TRUE));
}
/**
* Some common languages with their English and native names.
*
* Language codes are defined by the W3C language tags document for
* interoperability. Language codes typically have a language and optionally,
* a script or regional variant name. See
* http://www.w3.org/International/articles/language-tags/ for more information.
*
* This list is based on languages available from localize.drupal.org. See
* http://localize.drupal.org/issues for information on how to add languages
* there.
*
* The "Left-to-right marker" comments and the enclosed UTF-8 markers are to
* make otherwise strange looking PHP syntax natural (to not be displayed in
* right to left). See http://drupal.org/node/128866#comment-528929.
*
* @return array
* An array of language code to language name information.
* Language name information itself is an array of English and native names.
*/
public static function getStandardLanguageList() {
return array(
'af' => array('Afrikaans', 'Afrikaans'),
'am' => array('Amharic', 'አማርኛ'),
'ar' => array('Arabic', /* Left-to-right marker "‭" */ 'العربية', Language::DIRECTION_RTL),
'ast' => array('Asturian', 'Asturianu'),
'az' => array('Azerbaijani', 'Azərbaycanca'),
'be' => array('Belarusian', 'Беларуская'),
'bg' => array('Bulgarian', 'Български'),
'bn' => array('Bengali', 'বাংলা'),
'bo' => array('Tibetan', 'བོད་སྐད་'),
'bs' => array('Bosnian', 'Bosanski'),
'ca' => array('Catalan', 'Català'),
'cs' => array('Czech', 'Čeština'),
'cy' => array('Welsh', 'Cymraeg'),
'da' => array('Danish', 'Dansk'),
'de' => array('German', 'Deutsch'),
'dz' => array('Dzongkha', 'རྫོང་ཁ'),
'el' => array('Greek', 'Ελληνικά'),
'en' => array('English', 'English'),
'eo' => array('Esperanto', 'Esperanto'),
'es' => array('Spanish', 'Español'),
'et' => array('Estonian', 'Eesti'),
'eu' => array('Basque', 'Euskera'),
'fa' => array('Persian, Farsi', /* Left-to-right marker "‭" */ 'فارسی', Language::DIRECTION_RTL),
'fi' => array('Finnish', 'Suomi'),
'fil' => array('Filipino', 'Filipino'),
'fo' => array('Faeroese', 'Føroyskt'),
'fr' => array('French', 'Français'),
'gd' => array('Scots Gaelic', 'Gàidhlig'),
'gl' => array('Galician', 'Galego'),
'gsw-berne' => array('Swiss German', 'Schwyzerdütsch'),
'gu' => array('Gujarati', 'ગુજરાતી'),
'he' => array('Hebrew', /* Left-to-right marker "‭" */ 'עברית', Language::DIRECTION_RTL),
'hi' => array('Hindi', 'हिन्दी'),
'hr' => array('Croatian', 'Hrvatski'),
'ht' => array('Haitian Creole', 'Kreyòl ayisyen'),
'hu' => array('Hungarian', 'Magyar'),
'id' => array('Indonesian', 'Bahasa Indonesia'),
'is' => array('Icelandic', 'Íslenska'),
'it' => array('Italian', 'Italiano'),
'ja' => array('Japanese', '日本語'),
'jv' => array('Javanese', 'Basa Java'),
'ka' => array('Georgian', 'ქართული ენა'),
'kk' => array('Kazakh', 'Қазақ'),
'kn' => array('Kannada', 'ಕನ್ನಡ'),
'ko' => array('Korean', '한국어'),
'ku' => array('Kurdish', 'Kurdî'),
'ky' => array('Kyrgyz', 'Кыргызча'),
'lo' => array('Lao', 'ພາສາລາວ'),
'lt' => array('Lithuanian', 'Lietuvių'),
'lv' => array('Latvian', 'Latviešu'),
'mg' => array('Malagasy', 'Malagasy'),
'mk' => array('Macedonian', 'Македонски'),
'ml' => array('Malayalam', 'മലയാളം'),
'mn' => array('Mongolian', 'монгол'),
'mr' => array('Marathi', 'मराठी'),
'my' => array('Burmese', 'ဗမာစကား'),
'ne' => array('Nepali', 'नेपाली'),
'nl' => array('Dutch', 'Nederlands'),
'nb' => array('Norwegian Bokmål', 'Bokmål'),
'nn' => array('Norwegian Nynorsk', 'Nynorsk'),
'oc' => array('Occitan', 'Occitan'),
'pa' => array('Punjabi', 'ਪੰਜਾਬੀ'),
'pl' => array('Polish', 'Polski'),
'pt-pt' => array('Portuguese, Portugal', 'Português, Portugal'),
'pt-br' => array('Portuguese, Brazil', 'Português, Brasil'),
'ro' => array('Romanian', 'Română'),
'ru' => array('Russian', 'Русский'),
'sco' => array('Scots', 'Scots'),
'se' => array('Northern Sami', 'Sámi'),
'si' => array('Sinhala', 'සිංහල'),
'sk' => array('Slovak', 'Slovenčina'),
'sl' => array('Slovenian', 'Slovenščina'),
'sq' => array('Albanian', 'Shqip'),
'sr' => array('Serbian', 'Српски'),
'sv' => array('Swedish', 'Svenska'),
'ta' => array('Tamil', 'தமிழ்'),
'ta-lk' => array('Tamil, Sri Lanka', 'தமிழ், இலங்கை'),
'te' => array('Telugu', 'తెలుగు'),
'th' => array('Thai', 'ภาษาไทย'),
'tr' => array('Turkish', 'Türkçe'),
'tyv' => array('Tuvan', 'Тыва дыл'),
'ug' => array('Uyghur', 'Уйғур'),
'uk' => array('Ukrainian', 'Українська'),
'ur' => array('Urdu', /* Left-to-right marker "‭" */ 'اردو', Language::DIRECTION_RTL),
'vi' => array('Vietnamese', 'Tiếng Việt'),
'xx-lolspeak' => array('Lolspeak', 'Lolspeak'),
'zh-hans' => array('Chinese, Simplified', '简体中文'),
'zh-hant' => array('Chinese, Traditional', '繁體中文'),
);
}
}
......@@ -6,6 +6,7 @@
*/
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageManager;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
......@@ -334,9 +335,8 @@ function language_admin_delete_form_submit($form, &$form_state) {
* Prepare a language code list for unused predefined languages.
*/
function language_admin_predefined_list() {
include_once DRUPAL_ROOT . '/core/includes/standard.inc';
$languages = language_list();
$predefined = standard_language_list();
$predefined = LanguageManager::getStandardLanguageList();
foreach ($predefined as $key => $value) {
if (isset($languages[$key])) {
unset($predefined[$key]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment