1 | /*
|
2 | * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved.
|
3 | *
|
4 | * Permission is hereby granted, free of charge, to any person obtaining a
|
5 | * copy of this software and associated documentation files (the "Software"),
|
6 | * to deal in the Software without restriction, including without limitation
|
7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
8 | * and/or sell copies of the Software, and to permit persons to whom the
|
9 | * Software is furnished to do so, subject to the following conditions:
|
10 | *
|
11 | * The above copyright notice and this permission notice shall be included in
|
12 | * all copies or substantial portions of the Software.
|
13 | *
|
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
20 | * DEALINGS IN THE SOFTWARE.
|
21 | *
|
22 | */
|
23 |
|
24 | /*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
|
25 | /*global define, brackets */
|
26 |
|
27 | /**
|
28 | * This file provides the interface to user visible strings in Brackets. Code that needs
|
29 | * to display strings should should load this module by calling var Strings = require("strings").
|
30 | * The i18n plugin will dynamically load the strings for the right locale and populate
|
31 | * the exports variable. See src\nls\strings.js for the master file of English strings.
|
32 | */
|
33 | define(function (require, exports, module) {
|
34 | ;
|
35 |
|
36 | var strings = require("i18n!nls/strings"),
|
37 | Global = require("utils/Global"),
|
38 | StringUtils = require("utils/StringUtils");
|
39 |
|
40 | var additionalGlobals = {},
|
41 | parsedVersion = /([0-9]+)\.([0-9]+)\.([0-9]+)/.exec(brackets.metadata.version);
|
42 |
|
43 | additionalGlobals.APP_NAME = brackets.metadata.name || strings.APP_NAME;
|
44 | additionalGlobals.APP_TITLE = brackets.config.app_title || strings.APP_NAME;
|
45 | additionalGlobals.VERSION = brackets.metadata.version;
|
46 | additionalGlobals.VERSION_MAJOR = parsedVersion[1];
|
47 | additionalGlobals.VERSION_MINOR = parsedVersion[2];
|
48 | additionalGlobals.VERSION_PATCH = parsedVersion[3];
|
49 |
|
50 | // Insert application strings
|
51 | Object.keys(strings).forEach(function (key) {
|
52 | Object.keys(additionalGlobals).forEach(function (name) {
|
53 | strings[key] = strings[key].replace(new RegExp("{" + name + "}", "g"), additionalGlobals[name]);
|
54 | });
|
55 | });
|
56 |
|
57 | module.exports = strings;
|
58 |
|
59 | }); |
\ | No newline at end of file |