15fd8c73ee0630a82dd243769a1044d8c707a3eb
[Packages/TYPO3.CMS.git] / typo3 / sysext / lang / Resources / Public / JavaScript / Lang.js
1 /*
2 * This file is part of the TYPO3 CMS project.
3 *
4 * It is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License, either version 2
6 * of the License, or any later version.
7 *
8 * For the full copyright and license information, please read the
9 * LICENSE.txt file that was distributed with this source code.
10 *
11 * The TYPO3 project - inspiring people to share!
12 */
13
14 /**
15 * Transforms the TYPO3.lang object into a flat object
16 *
17 * `TYPO3.lang.foo[0].target = 'blah'` becomes `TYPO3.lang['foo'] = 'blah'`
18 */
19 define('TYPO3/CMS/Lang/Lang', ['jquery'], function($) {
20 var Lang = {};
21
22 Lang.convertToOneDimension = function() {
23 var originalLangObject = $.extend(true, {}, TYPO3.lang);
24 TYPO3.lang = [];
25 $.each(originalLangObject, function(index, value) {
26 TYPO3.lang[index] = value[0].target || value[0].source;
27 });
28
29 delete originalLangObject;
30 };
31
32 Lang.convertToOneDimension();
33 return TYPO3.lang;
34 });