8651ae47a33e24b0c524425ba8e6304a27a2f077
[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 * Module: TYPO3/CMS/Lang/Lang
16 * Transforms the TYPO3.lang object into a flat object
17 *
18 * `TYPO3.lang.foo[0].target = 'blah'` becomes `TYPO3.lang['foo'] = 'blah'`
19 */
20 define(['jquery'], function($) {
21 /**
22 *
23 * @type {{}}
24 * @exports TYPO3/CMS/Lang/Lang
25 */
26 var Lang = {};
27
28 /**
29 *
30 */
31 Lang.convertToOneDimension = function() {
32 var originalLangObject = $.extend(true, {}, TYPO3.lang);
33 TYPO3.lang = [];
34 $.each(originalLangObject, function(index, value) {
35 if (typeof value !== "undefined" && typeof value[0] !== "undefined") {
36 TYPO3.lang[index] = value[0].target || value[0].source;
37 } else {
38 TYPO3.lang[index] = value;
39 }
40 });
41
42 delete originalLangObject;
43 };
44
45 Lang.convertToOneDimension();
46 return TYPO3.lang;
47 });