[FEATURE] Add support for locales
authorXavier Perseguers <typo3@perseguers.ch>
Fri, 15 Jul 2011 13:13:34 +0000 (15:13 +0200)
committerJigal van Hemert <jigal@xs4all.nl>
Mon, 1 Aug 2011 17:39:18 +0000 (19:39 +0200)
Add a new class t3lib_l10n_Locales that is responsible to handle
locales such as fr_CA within TYPO3 and add support for locales
dependencies in Extension Manager.

Change-Id: If5976fc7bfbe82d347a9d84a5ebac84dcc4c76a2
Resolves: #28239
Reviewed-on: http://review.typo3.org/3359
Reviewed-by: Steffen Kamper
Tested-by: Steffen Kamper
Tested-by: Xavier Perseguers
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
13 files changed:
t3lib/class.t3lib_cs.php
t3lib/class.t3lib_pagerenderer.php
t3lib/config_default.php
t3lib/core_autoload.php
t3lib/l10n/class.t3lib_l10n_locales.php [new file with mode: 0644]
t3lib/stddb/tbl_be.php
typo3/sysext/em/classes/connection/class.tx_em_connection_extdirectserver.php
typo3/sysext/em/classes/translations/class.tx_em_translations.php
typo3/sysext/em/language/locallang.xml
typo3/sysext/em/res/js/em_languages.js
typo3/sysext/lang/lang.php
typo3/sysext/setup/mod/index.php
typo3/sysext/setup/mod/locallang.xml

index 38cadf5..75273e2 100644 (file)
  * @subpackage t3lib
  */
 class t3lib_cs {
+
+       /**
+        * @var t3lib_l10n_Locales
+        */
+       protected $locales;
+
        var $noCharByteVal = 63; // ASCII Value for chars with no equivalent.
 
                // This is the array where parsed conversion tables are stored (cached)
@@ -406,60 +412,76 @@ class t3lib_cs {
                // TYPO3 specific: Array with the system charsets used for each system language in TYPO3:
                // Empty values means "iso-8859-1"
        var $charSetArray = array(
-               'dk' => '',
+               'ar' => 'iso-8859-6',
+               'ba' => 'iso-8859-2',
+               'bg' => 'windows-1251',
+               'br' => '',
+               'ca' => 'iso-8859-15',
+               'ch' => 'gb2312',
+               'cs' => 'windows-1250',
+               'cz' => 'windows-1250',
+               'da' => '',
                'de' => '',
-               'no' => '',
-               'it' => '',
-               'fr' => '',
+               'dk' => '',
+               'el' => 'iso-8859-7',
+               'eo' => 'utf-8',
                'es' => '',
-               'nl' => '',
-               'cz' => 'windows-1250',
-               'pl' => 'iso-8859-2',
-               'si' => 'windows-1250',
+               'et' => 'iso-8859-4',
+               'eu' => '',
+               'fa' => 'utf-8',
                'fi' => '',
-               'tr' => 'iso-8859-9',
-               'se' => '',
-               'pt' => '',
-               'ru' => 'windows-1251',
-               'ro' => 'iso-8859-2',
-               'ch' => 'gb2312',
-               'sk' => 'windows-1250',
-               'lt' => 'windows-1257',
-               'is' => 'utf-8',
-               'hr' => 'windows-1250',
-               'hu' => 'iso-8859-2',
+               'fo' => 'utf-8',
+               'fr' => '',
+               'fr_CA' => '',
+               'ga' => '',
+               'ge' => 'utf-8',
                'gl' => '',
-               'th' => 'iso-8859-11',
                'gr' => 'iso-8859-7',
-               'hk' => 'big5',
-               'eu' => '',
-               'bg' => 'windows-1251',
-               'br' => '',
-               'et' => 'iso-8859-4',
-               'ar' => 'iso-8859-6',
                'he' => 'utf-8',
-               'ua' => 'windows-1251',
+               'hi' => 'utf-8',
+               'hk' => 'big5',
+               'hr' => 'windows-1250',
+               'hu' => 'iso-8859-2',
+               'is' => 'utf-8',
+               'it' => '',
+               'ja' => 'shift_jis',
                'jp' => 'shift_jis',
-               'lv' => 'utf-8',
-               'vn' => 'utf-8',
-               'ca' => 'iso-8859-15',
-               'ba' => 'iso-8859-2',
+               'ka' => 'utf-8',
+               'kl' => 'utf-8',
+               'km' => 'utf-8',
+               'ko' => 'euc-kr',
                'kr' => 'euc-kr',
-               'eo' => 'utf-8',
+               'lt' => 'windows-1257',
+               'lv' => 'utf-8',
+               'ms' => '',
                'my' => '',
-               'hi' => 'utf-8',
-               'fo' => 'utf-8',
-               'fa' => 'utf-8',
-               'sr' => 'utf-8',
-               'sq' => 'utf-8',
-               'ge' => 'utf-8',
-               'ga' => '',
-               'km' => 'utf-8',
+               'nl' => '',
+               'no' => '',
+               'pl' => 'iso-8859-2',
+               'pt' => '',
+               'pt_BR' => '',
                'qc' => '',
+               'ro' => 'iso-8859-2',
+               'ru' => 'windows-1251',
+               'se' => '',
+               'si' => 'windows-1250',
+               'sk' => 'windows-1250',
+               'sl' => 'windows-1250',
+               'sq' => 'utf-8',
+               'sr' => 'utf-8',
+               'sv' => '',
+               'th' => 'iso-8859-11',
+               'tr' => 'iso-8859-9',
+               'ua' => 'windows-1251',
+               'uk' => 'windows-1251',
+               'vi' => 'utf-8',
+               'vn' => 'utf-8',
+               'zh' => 'big5',
        );
 
                // TYPO3 specific: Array with the iso names used for each system language in TYPO3:
-               // Missing keys means: same as Typo3
+               // Missing keys means: same as TYPO3
+               // @deprecated since TYPO3 4.6, will be removed in TYPO3 4.8 - use t3lib_l10n_Locales::getIsoMapping()
        var $isoArray = array(
                'ba' => 'bs',
                'br' => 'pt_BR',
@@ -481,6 +503,13 @@ class t3lib_cs {
        );
 
        /**
+        * Default constructor.
+        */
+       public function __construct() {
+               $this->locales = t3lib_div::makeInstance('t3lib_l10n_Locales');
+       }
+
+       /**
         * Normalize - changes input character set to lowercase letters.
         *
         * @param       string          Input charset
@@ -1705,7 +1734,7 @@ class t3lib_cs {
                        // get all languages where TYPO3 code differs from ISO code
                        // or needs the country part
                        // the iso codes will here overwrite the default typo3 language in the key
-               foreach ($this->isoArray as $typo3Lang => $isoLang) {
+               foreach ($this->locales->getIsoMapping() as $typo3Lang => $isoLang) {
                        $isoLang = join('-', explode('_', $isoLang));
                        $allLanguageCodes[$typo3Lang] = $isoLang;
                }
index a328552..e524f92 100644 (file)
@@ -47,11 +47,13 @@ class t3lib_PageRenderer implements t3lib_Singleton {
 
        protected $moveJsFromHeaderToFooter = FALSE;
 
-       /* @var t3lib_cs Instance of t3lib_cs */
+       /** @var t3lib_cs $csConvObj */
        protected $csConvObj;
+       /** @var t3lib_l10n_Locales */
+       protected $locales;
        protected $lang;
 
-       /* @var t3lib_Compressor Instance of t3lib_Compressor */
+       /** @var t3lib_Compressor $compressor */
        protected $compressor;
 
                // arrays containing associative array for the included files
@@ -156,6 +158,7 @@ class t3lib_PageRenderer implements t3lib_Singleton {
 
                $this->reset();
                $this->csConvObj = t3lib_div::makeInstance('t3lib_cs');
+               $this->locales = t3lib_div::makeInstance('t3lib_l10n_Locales');
 
                if (strlen($templateFile)) {
                        $this->templateFile = $templateFile;
@@ -1776,7 +1779,7 @@ class t3lib_PageRenderer implements t3lib_Singleton {
                                        '" type="text/javascript"></script>' . LF;
 
                                // add extJS localization
-                       $localeMap = $this->csConvObj->isoArray; // load standard ISO mapping and modify for use with ExtJS
+                       $localeMap = $this->locales->getIsoMapping(); // load standard ISO mapping and modify for use with ExtJS
                        $localeMap[''] = 'en';
                        $localeMap['default'] = 'en';
                        $localeMap['gr'] = 'el_GR'; // Greek
index 598ae48..d7e4199 100644 (file)
@@ -903,15 +903,8 @@ define('TYPO3_db_host', $typo_db_host);
 define('TYPO3_tables_script', $typo_db_tables_script);
 define('TYPO3_extTableDef_script', $typo_db_extTableDef_script);
 
-       // Defining backend system languages
-       // When adding new keys, remember to:
-       //              - Update pages.lang item array (t3lib/stddb/tbl_be.php)
-       //              - Add character encoding for lang. key in t3lib/class.t3lib_cs.php (default for new languages is "utf-8")
-       //              - Add mappings for language in t3lib/class.t3lib_cs.php (TYPO3/ISO, language/script, script/charset)
-       //              - Update 'setup' extension labels (sysext/setup/mod/locallang.xml)
-       //              - Using translation server? Create new user with username = "language key", member of "translator" group, set to "language key" language.
-       // Thats it! Use extension "llxmltranslate" to begin translation. Language pack is automatically created in "typo3conf/l10n/[language key]/"
-define('TYPO3_languages', 'default|dk|de|no|it|fr|es|nl|cz|pl|si|fi|tr|se|pt|ru|ro|ch|sk|lt|is|hr|hu|gl|th|gr|hk|eu|bg|br|et|ar|he|ua|lv|jp|vn|ca|ba|kr|eo|my|hi|fo|fa|sr|sq|ge|ga|km|qc');
+       // Initialize the locales handled by TYPO3
+t3lib_l10n_Locales::initialize();
 
        // Unsetting the configured values. Use of these are deprecated.
 unset($typo_db);
index 7701923..8199932 100644 (file)
@@ -43,6 +43,7 @@ $t3libClasses = array(
        't3lib_l10n_exception_filenotfound' => PATH_t3lib . 'l10n/exception/class.t3lib_l10n_exception_filenotfound.php',
        't3lib_l10n_exception_invalidparser' => PATH_t3lib . 'l10n/exception/class.t3lib_l10n_exception_invalidparser.php',
        't3lib_l10n_exception_invalidxmlfile' => PATH_t3lib . 'l10n/exception/class.t3lib_l10n_exception_invalidxmlfile.php',
+       't3lib_l10n_locales' => PATH_t3lib . 'l10n/class.t3lib_l10n_locales.php',
        't3lib_l10n_parser' => PATH_t3lib . 'l10n/interfaces/interface.t3lib_l10n_parser.php',
        't3lib_l10n_parser_abstractxml' => PATH_t3lib . 'l10n/parser/class.t3lib_l10n_parser_abstractxml.php',
        't3lib_l10n_parser_llphp' => PATH_t3lib . 'l10n/parser/class.t3lib_l10n_parser_llphp.php',
diff --git a/t3lib/l10n/class.t3lib_l10n_locales.php b/t3lib/l10n/class.t3lib_l10n_locales.php
new file mode 100644 (file)
index 0000000..6046b13
--- /dev/null
@@ -0,0 +1,255 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2011 Xavier Perseguers <typo3@perseguers.ch>
+ *  All rights reserved
+ *
+ *  This script is part of the TYPO3 project. The TYPO3 project is
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+
+/**
+ * Locales.
+ *
+ * Defining backend system languages
+ * When adding new keys, remember to:
+ *             - Update pages.lang item array (t3lib/stddb/tbl_be.php)
+ *             - Add character encoding for lang. key in t3lib/class.t3lib_cs.php (default for new languages is "utf-8")
+ *             - Add mappings for language in t3lib/class.t3lib_cs.php (TYPO3/ISO, language/script, script/charset)
+ *             - Update 'setup' extension labels (sysext/setup/mod/locallang.xml)
+ * That's it!
+ *
+ * @package    Core
+ * @subpackage t3lib
+ * @author     Xavier Perseguers <typo3@perseguers.ch>
+ */
+class t3lib_l10n_Locales implements t3lib_Singleton {
+
+       /**
+        * Supported TYPO3 locales
+        * @var array
+        */
+       protected $locales = array(
+               'default',      // English
+               'ar',           // Arabic
+               'bs',           // Bosnian
+               'bg',           // Bulgarian
+               'ca',           // Catalan; Valencian
+               'ch',           // Chinese (Simplified)
+               'cs',           // Czech
+               'da',           // Danish
+               'de',           // German
+               'el',           // Greek
+               'eo',           // Esperanto
+               'es',           // Spanish; Castilian
+               'et',           // Estonian
+               'eu',           // Basque
+               'fa',           // Persian
+               'fi',           // Finnish
+               'fo',           // Faroese
+               'fr',           // French
+               'fr_CA',        // French (Canada)
+               'gl',           // Galician
+               'he',           // Hebrew
+               'hi',           // Hindi
+               'hr',           // Croatian
+               'hu',           // Hungarian
+               'is',           // Icelandic
+               'it',           // Italian
+               'ja',           // Japanese
+               'ka',           // Georgian
+               'kl',           // Greenlandic
+               'km',           // Khmer
+               'ko',           // Korean
+               'lt',           // Lithuanian
+               'lv',           // Latvian
+               'ms',           // Malay
+               'nl',           // Dutch
+               'no',           // Norwegian
+               'pl',           // Polish
+               'pt',           // Portuguese
+               'pt_BR',        // Portuguese (Brazil)
+               'ro',           // Romanian
+               'ru',           // Russian
+               'sk',           // Slovak
+               'sl',           // Slovenian
+               'sq',           // Albanian
+               'sr',           // Serbian
+               'sv',           // Swedish
+               'th',           // Thai
+               'tr',           // Turkish
+               'uk',           // Ukrainian
+               'vi',           // Vietnamese
+               'zh',           // Chinese (China)
+       );
+
+       /**
+        * Mapping with codes used by TYPO3 4.5 and below
+        * @var array
+        */
+       protected $isoReverseMapping = array(
+               'bs' => 'ba',           // Bosnian
+               'cs' => 'cz',           // Czech
+               'da' => 'dk',           // Danish
+               'el' => 'gr',           // Greek
+               'fr_CA' => 'qc',        // French (Canada)
+               'gl' => 'ga',           // Galician
+               'ja' => 'jp',           // Japanese
+               'ka' => 'ge',           // Georgian
+               'kl' => 'gl',           // Greenlandic
+               'ko' => 'kr',           // Korean
+               'ms' => 'my',           // Malay
+               'pt_BR' => 'br',        // Portuguese (Brazil)
+               'sl' => 'si',           // Slovenian
+               'sv' => 'se',           // Swedish
+               'uk' => 'ua',           // Ukrainian
+               'vi' => 'vn',           // Vietnamese
+               'zh' => 'hk',           // Chinese (China)
+               'zh_CN' => 'ch',        // Chinese (Simplified)
+               'zh_HK' => 'hk',        // Chinese (China)
+       );
+
+       /**
+        * @var array
+        */
+       protected $isoMapping;
+
+       /**
+        * Dependencies for locales
+        * @var array
+        */
+       protected $localeDependencies;
+
+       /**
+        * Initializes the languages.
+        *
+        * @static
+        * @return void
+        */
+       public static function initialize() {
+               /** @var $instance t3lib_l10n_Locales */
+               $instance = t3lib_div::makeInstance('t3lib_l10n_Locales');
+               $instance->isoMapping = array_flip($instance->isoReverseMapping);
+
+                       // Initializes the locale dependencies with TYPO3 supported locales
+               $instance->localeDependencies = array();
+               foreach ($instance->locales as $locale) {
+                       if (strlen($locale) == 5) {
+                               $instance->localeDependencies[$locale] = array(substr($locale, 0, 2));
+                       }
+               }
+                       // Merge user-provided locale dependencies
+               if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['dependencies']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['dependencies'])) {
+                       $instance->localeDependencies = t3lib_div::array_merge_recursive_overrule($instance->localeDependencies, $GLOBALS['TYPO3_CONF_VARS']['SYS']['localization']['locales']['dependencies']);
+               }
+
+               /**
+                * @deprecated since TYPO3 4.6, will be removed in TYPO3 4.8
+                */
+               define('TYPO3_languages', implode('|', $instance->getLocales()));
+       }
+
+       /**
+        * Returns the locales.
+        *
+        * @return array
+        */
+       public function getLocales() {
+               return $this->locales;
+       }
+
+       /**
+        * Returns the mapping between TYPO3 (old) language codes and ISO codes.
+        *
+        * @return array
+        */
+       public function getIsoMapping() {
+               return $this->isoMapping;
+       }
+
+       /**
+        * Returns the locales as referenced by the TER and TYPO3 localization files.
+        *
+        * @return array
+        * @deprecated since TYPO3 4.6
+        */
+       public function getTerLocales() {
+               return $this->convertToTerLocales($this->locales);
+       }
+
+       /**
+        * Returns the dependencies of a given locale, if any.
+        *
+        * @param string $locale
+        * @return array
+        */
+       public function getLocaleDependencies($locale) {
+               $dependencies = array();
+               if (isset($this->localeDependencies[$locale])) {
+                       $dependencies = $this->localeDependencies[$locale];
+
+                               // Search for dependencies recursively
+                       $localeDependencies = $dependencies;
+                       foreach ($localeDependencies as $dependency) {
+                               if (isset($this->localeDependencies[$dependency])) {
+                                       $dependencies = array_merge($dependencies, $this->getLocaleDependencies($dependency));
+                               }
+                       }
+               }
+               return $dependencies;
+       }
+
+       /**
+        * Returns the dependencies of a given locale using TER compatible locale codes.
+        *
+        * @param string $locale
+        * @return array
+        * @deprecated since TYPO3 4.6
+        */
+       public function getTerLocaleDependencies($locale) {
+               $terLocale = isset($this->isoMapping[$locale])
+                               ? $this->isoMapping[$locale]
+                               : $locale;
+               return $this->convertToTerLocales($this->getLocaleDependencies($terLocale));
+       }
+
+       /**
+        * Converts an array of ISO locale codes into their TER equivalent.
+        *
+        * @param array $locales
+        * @return array
+        * @deprecated since TYPO3 4.6
+        */
+       protected function convertToTerLocales(array $locales) {
+               $terLocales = array();
+               foreach ($locales as $locale) {
+                       $terLocales[] = isset($this->isoReverseMapping[$locale]) ? $this->isoReverseMapping[$locale] : $locale;
+               }
+               return $terLocales;
+       }
+
+}
+
+
+if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/l10n/class.t3lib_l10n_locales.php'])) {
+       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/l10n/class.t3lib_l10n_locales.php']);
+}
+
+?>
\ No newline at end of file
index b84ca0d..a6a26e3 100644 (file)
@@ -283,38 +283,38 @@ $TCA['be_users'] = array(
                                        array('Albanian', 'sq'),
                                        array('Arabic', 'ar'),
                                        array('Basque', 'eu'),
-                                       array('Bosnian', 'ba'),
-                                       array('Brazilian Portuguese', 'br'),
+                                       array('Bosnian', 'bs'),
+                                       array('Brazilian Portuguese', 'pt_BR'),
                                        array('Bulgarian', 'bg'),
                                        array('Catalan', 'ca'),
                                        array('Chinese (Simpl.)', 'ch'),
-                                       array('Chinese (Trad.)', 'hk'),
+                                       array('Chinese (Trad.)', 'zh'),
                                        array('Croatian', 'hr'),
-                                       array('Czech', 'cz'),
-                                       array('Danish', 'dk'),
+                                       array('Czech', 'cs'),
+                                       array('Danish', 'da'),
                                        array('Dutch', 'nl'),
                                        array('Esperanto', 'eo'),
                                        array('Estonian', 'et'),
                                        array('Faroese', 'fo'),
                                        array('Finnish', 'fi'),
                                        array('French', 'fr'),
-                                       array('French (Canada)', 'qc'),
-                                       array('Galician', 'ga'),
-                                       array('Georgian', 'ge'),
+                                       array('French (Canada)', 'fr_CA'),
+                                       array('Galician', 'gl'),
+                                       array('Georgian', 'ka'),
                                        array('German', 'de'),
-                                       array('Greek', 'gr'),
-                                       array('Greenlandic', 'gl'),
+                                       array('Greek', 'el'),
+                                       array('Greenlandic', 'kl'),
                                        array('Hebrew', 'he'),
                                        array('Hindi', 'hi'),
                                        array('Hungarian', 'hu'),
                                        array('Icelandic', 'is'),
                                        array('Italian', 'it'),
-                                       array('Japanese', 'jp'),
+                                       array('Japanese', 'ja'),
                                        array('Khmer', 'km'),
-                                       array('Korean', 'kr'),
+                                       array('Korean', 'ko'),
                                        array('Latvian', 'lv'),
                                        array('Lithuanian', 'lt'),
-                                       array('Malay', 'my'),
+                                       array('Malay', 'ms'),
                                        array('Norwegian', 'no'),
                                        array('Persian', 'fa'),
                                        array('Polish', 'pl'),
@@ -323,13 +323,13 @@ $TCA['be_users'] = array(
                                        array('Russian', 'ru'),
                                        array('Serbian', 'sr'),
                                        array('Slovak', 'sk'),
-                                       array('Slovenian', 'si'),
+                                       array('Slovenian', 'sl'),
                                        array('Spanish', 'es'),
-                                       array('Swedish', 'se'),
+                                       array('Swedish', 'sv'),
                                        array('Thai', 'th'),
                                        array('Turkish', 'tr'),
-                                       array('Ukrainian', 'ua'),
-                                       array('Vietnamese', 'vn'),
+                                       array('Ukrainian', 'uk'),
+                                       array('Vietnamese', 'vi'),
                                )
                        )
                ),
index 60942f9..f406380 100644 (file)
@@ -1144,7 +1144,9 @@ class tx_em_Connection_ExtDirectServer {
                $this->globalSettings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['em']);
                $selected = t3lib_div::trimExplode(',', $this->globalSettings['selectedLanguages'], TRUE);
 
-               $theLanguages = t3lib_div::trimExplode('|', TYPO3_languages);
+               /** @var $locales t3lib_l10n_Locales */
+               $locales = t3lib_div::makeInstance('t3lib_l10n_Locales');
+               $theLanguages = $locales->getLocales();
                        //drop default
                array_shift($theLanguages);
                $lang = $meta = array();
@@ -1181,6 +1183,17 @@ class tx_em_Connection_ExtDirectServer {
         * @return string
         */
        public function saveLanguageSelection($parameter) {
+                       // Add possible dependencies for selected languages
+               /** @var $locales t3lib_l10n_Locales */
+               $locales = t3lib_div::makeInstance('t3lib_l10n_Locales');
+               $dependencies = array();
+               foreach ($parameter as $language) {
+                       $dependencies = array_merge($dependencies, $locales->getLocaleDependencies($language));
+               }
+               if (count($dependencies) > 0) {
+                       $parameter = array_unique(array_merge($parameter, $dependencies));
+               }
+
                $this->globalSettings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['em']);
                $selected = t3lib_div::trimExplode(',', $this->globalSettings['selectedLanguages'], TRUE);
 
@@ -1198,9 +1211,10 @@ class tx_em_Connection_ExtDirectServer {
                $this->saveExtensionConfiguration($params);
 
                return array(
-                       'success' => TRUE,
+                       'success' => count($diff) > 0,
                        'dir' => $dir,
-                       'diff' => implode('', $diff)
+                       'diff' => array_values($diff),
+                       'languages' => $parameter
                );
        }
 
index 3269df9..e0d5831 100644 (file)
@@ -139,13 +139,15 @@ class tx_em_Translations {
                if (count($selectedLanguages) == 1 && empty($selectedLanguages[0])) {
                        $selectedLanguages = array();
                }
-               $theLanguages = t3lib_div::trimExplode('|', TYPO3_languages);
+               /** @var $locales t3lib_l10n_Locales */
+               $locales = t3lib_div::makeInstance('t3lib_l10n_Locales');
+               $theLanguages = $locales->getLocales();
                foreach ($theLanguages as $val) {
                        if ($val != 'default') {
                                $localLabel = '  -  [' . htmlspecialchars($GLOBALS['LOCAL_LANG']['default']['lang_' . $val][0]['target']) . ']';
                                $selected = (is_array($selectedLanguages) && in_array($val, $selectedLanguages)) ? ' selected="selected"' : '';
                                $opt[$GLOBALS['LANG']->getLL('lang_' . $val, 1) . '--' . $val] = '
-                        <option value="' . $val . '"' . $selected . '>' . $LANG->getLL('lang_' . $val, 1) . $localLabel . '</option>';
+                        <option value="' . $val . '"' . $selected . '>' . $GLOBALS['LANG']->getLL('lang_' . $val, 1) . $localLabel . '</option>';
                        }
                }
                ksort($opt);
index 37bf1e3..e31499e 100644 (file)
                        <label index="translation_loaded_exts">To request an update or installation for already loaded extensions, see below.</label>
                        <label index="translation_save_selection">Save selection</label>
                        <label index="translation_selection_saved">Language selection was saved</label>
+                       <label index="translation_selection_impossible">Language selection was not possible due language dependency!</label>
                        <label index="translation_check_status_button">Check status against repository</label>
                        <label index="translation_update_button">Update from repository</label>
                        <label index="translation_status">Translation status</label>
index e75030b..c7e1bb2 100644 (file)
@@ -260,8 +260,10 @@ TYPO3.EM.Languages = Ext.extend(Ext.FormPanel, {
                TYPO3.EM.Languages.superclass.initComponent.apply(this, arguments);
                this.langGrid = Ext.getCmp('em-languagegrid');
                this.langGrid.getSelectionModel().on('selectionchange', function(){
-                       this.langGrid.disable();
-                       this.saveSelection();
+                       if (this.languageLoaded) {
+                               this.langGrid.disable();
+                               this.saveSelection();
+                       }
                }, this);
                Ext.getCmp('lang-checkbutton').handler = this.langActionHandler.createDelegate(this);
                Ext.getCmp('lang-updatebutton').handler = this.langActionHandler.createDelegate(this);
@@ -351,9 +353,31 @@ TYPO3.EM.Languages = Ext.extend(Ext.FormPanel, {
                if (this.languageLoaded === true) {
                        this.getSelectedLanguages();
                        TYPO3.EM.ExtDirect.saveLanguageSelection(this.selectedLanguages, function(response) {
-                               record = this.langStore.getById(response.diff);
-                               this.addRemoveExtLanguageGridColumn(record.data);
-                       },this);
+                               this.languageLoaded = false;
+                               if (response.success) {
+                                       for (var i = 0; i < response.diff.length; i++) {
+                                               record = this.langStore.getById(response.diff[i]);
+                                               this.addRemoveExtLanguageGridColumn(record.data);
+                                               if (response.dir > 0) {
+                                                               // Languages were added
+                                                       this.langGrid.getSelectionModel().selectRow(this.langGrid.store.indexOf(record), true);
+                                               } else {
+                                                               // Languages were removed
+                                                       this.langGrid.getSelectionModel().deselectRow(this.langGrid.store.indexOf(record), true);
+                                               }
+                                       }
+                               } else {
+                                       // Action not possible because of dependencies
+                                       // Select all languages saved again and output the message
+                                       for (var i = 0; i < response.languages.length; i++) {
+                                               record = this.langStore.getById(response.languages[i]);
+                                               this.langGrid.getSelectionModel().selectRow(this.langGrid.store.indexOf(record), true);
+                                       }
+                                       TYPO3.Flashmessage.display(TYPO3.Severity.error, TYPO3.l10n.localize('translation_settings'), TYPO3.l10n.localize('translation_selection_impossible'), 5);
+                                       this.langGrid.enable();
+                               }
+                               this.languageLoaded = true;
+                       }, this);
                        if (this.selectedLanguages.length) {
                                Ext.getCmp('lang-checkbutton').enable();
                                Ext.getCmp('lang-updatebutton').enable();
index 8f5f8c6..53dd2e5 100755 (executable)
@@ -139,10 +139,11 @@ class language {
 
                        // Finding the requested language in this list based
                        // on the $lang key being inputted to this function.
-               $ls = explode('|', TYPO3_languages);
+               /** @var $locales t3lib_l10n_Locales */
+               $locales = t3lib_div::makeInstance('t3lib_l10n_Locales');
 
                        // Language is found. Configure it:
-               if (in_array($lang, $ls)) {
+               if (in_array($lang, $locales->getLocales())) {
                                // The current language key
                        $this->lang = $lang;
                        if ($this->charSetArray[$this->lang]) {
index 6468073..0af69c2 100755 (executable)
@@ -758,8 +758,9 @@ class SC_mod_user_setup_index {
                $languageOptions[$langDefault] = '<option value="">' . $langDefault . '</option>';
 
                        // traverse the number of languages
-               $theLanguages = t3lib_div::trimExplode('|', TYPO3_languages);
-               foreach ($theLanguages as $language) {
+               /** @var $locales t3lib_l10n_Locales */
+               $locales = t3lib_div::makeInstance('t3lib_l10n_Locales');
+               foreach ($locales->getLocales() as $language) {
                        if ($language != 'default') {
                                $languageValue = $GLOBALS['LOCAL_LANG']['default']['lang_' . $language][0]['source'];
                                $localLabel = '  -  ['.htmlspecialchars($languageValue) . ']';
index ddd41f3..b5b4955 100755 (executable)
@@ -9,56 +9,72 @@
                        <label index="UserSettings">User Settings</label>
                        <label index="language">Language</label>
                        <label index="lang_default">English</label>
+                       <label index="lang_ar">Arabic</label>
+                       <label index="lang_ba">Bosnian</label>
+                       <label index="lang_bs">Bosnian</label>
+                       <label index="lang_bg">Bulgarian</label>
+                       <label index="lang_ca">Catalan</label>
+                       <label index="lang_ch">Chinese (Simpl)</label>
+                       <label index="lang_cs">Czech</label>
+                       <label index="lang_cz">Czech</label>
+                       <label index="lang_da">Danish</label>
                        <label index="lang_dk">Danish</label>
                        <label index="lang_de">German</label>
-                       <label index="lang_no">Norwegian</label>
-                       <label index="lang_it">Italian</label>
-                       <label index="lang_fr">French</label>
+                       <label index="lang_el">Greek</label>
+                       <label index="lang_gr">Greek</label>
+                       <label index="lang_eo">Esperanto</label>
                        <label index="lang_es">Spanish</label>
+                       <label index="lang_et">Estonian</label>
+                       <label index="lang_eu">Basque</label>
+                       <label index="lang_fa">Persian</label>
+                       <label index="lang_fi">Finnish</label>
+                       <label index="lang_fo">Faroese</label>
+                       <label index="lang_fr">French</label>
+                       <label index="lang_fr_CA">French (Canada)</label>
+                       <label index="lang_qc">French (Canada)</label>
+                       <label index="lang_ga">Galician</label>
+                       <label index="lang_gl">Galician</label>
+                       <label index="lang_he">Hebrew</label>
+                       <label index="lang_hi">Hindi</label>
+                       <label index="lang_hr">Croatian</label>
+                       <label index="lang_hu">Hungarian</label>
+                       <label index="lang_is">Icelandic</label>
+                       <label index="lang_it">Italian</label>
+                       <label index="lang_ja">Japanese</label>
+                       <label index="lang_jp">Japanese</label>
+                       <label index="lang_ge">Georgian</label>
+                       <label index="lang_ka">Georgian</label>
+                       <label index="lang_kl">Greenlandic</label>
+                       <label index="lang_km">Khmer</label>
+                       <label index="lang_ko">Korean</label>
+                       <label index="lang_kr">Korean</label>
+                       <label index="lang_lt">Lithuanian</label>
+                       <label index="lang_lv">Latvian</label>
+                       <label index="lang_ms">Bahasa Malaysia</label>
+                       <label index="lang_my">Bahasa Malaysia</label>
                        <label index="lang_nl">Dutch</label>
-                       <label index="lang_cz">Czech</label>
+                       <label index="lang_no">Norwegian</label>
                        <label index="lang_pl">Polish</label>
-                       <label index="lang_si">Slovenian</label>
-                       <label index="lang_fi">Finnish</label>
-                       <label index="lang_tr">Turkish</label>
-                       <label index="lang_se">Swedish</label>
                        <label index="lang_pt">Portuguese</label>
-                       <label index="lang_ru">Russian</label>
+                       <label index="lang_br">Brazilian Portuguese</label>
+                       <label index="lang_pt_BR">Brazilian Portuguese</label>
                        <label index="lang_ro">Romanian</label>
-                       <label index="lang_ch">Chinese (Simpl)</label>
+                       <label index="lang_ru">Russian</label>
                        <label index="lang_sk">Slovak</label>
-                       <label index="lang_lt">Lithuanian</label>
-                       <label index="lang_is">Icelandic</label>
-                       <label index="lang_hr">Croatian</label>
-                       <label index="lang_hu">Hungarian</label>
-                       <label index="lang_gl">Greenlandic</label>
+                       <label index="lang_si">Slovenian</label>
+                       <label index="lang_sl">Slovenian</label>
+                       <label index="lang_sq">Albanian</label>
+                       <label index="lang_sr">Serbian</label>
+                       <label index="lang_se">Swedish</label>
+                       <label index="lang_sv">Swedish</label>
                        <label index="lang_th">Thai</label>
-                       <label index="lang_gr">Greek</label>
-                       <label index="lang_hk">Chinese (Trad)</label>
-                       <label index="lang_eu">Basque</label>
-                       <label index="lang_bg">Bulgarian</label>
-                       <label index="lang_br">Brazilian Portuguese</label>
-                       <label index="lang_et">Estonian</label>
-                       <label index="lang_ar">Arabic</label>
-                       <label index="lang_he">Hebrew</label>
+                       <label index="lang_tr">Turkish</label>
                        <label index="lang_ua">Ukrainian</label>
-                       <label index="lang_lv">Latvian</label>
-                       <label index="lang_jp">Japanese</label>
+                       <label index="lang_uk">Ukrainian</label>
+                       <label index="lang_vi">Vietnamese</label>
                        <label index="lang_vn">Vietnamese</label>
-                       <label index="lang_ca">Catalan</label>
-                       <label index="lang_ba">Bosnian</label>
-                       <label index="lang_kr">Korean</label>
-                       <label index="lang_eo">Esperanto</label>
-                       <label index="lang_my">Bahasa Malaysia</label>
-                       <label index="lang_hi">Hindi</label>
-                       <label index="lang_fo">Faroese</label>
-                       <label index="lang_fa">Persian</label>
-                       <label index="lang_sr">Serbian</label>
-                       <label index="lang_sq">Albanian</label>
-                       <label index="lang_ge">Georgian</label>
-                       <label index="lang_ga">Galician</label>
-                       <label index="lang_km">Khmer</label>
-                       <label index="lang_qc">French (Canada)</label>
+                       <label index="lang_hk">Chinese (Trad)</label>
+                       <label index="lang_zh">Chinese (Trad)</label>
                        <label index="default">Default</label>
                        <label index="simulate">Simulate backend user</label>
                        <label index="opening">Startup</label>