Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/common/UIString.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). 4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).
5 * Copyright (C) 2009 Joseph Pecoraro 5 * Copyright (C) 2009 Joseph Pecoraro
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
(...skipping 10 matching lines...) Expand all
21 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 23 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31
32 self['Common'] = self['Common'] || {};
33
31 /** 34 /**
32 * @param {string} string 35 * @param {string} string
33 * @param {...*} vararg 36 * @param {...*} vararg
34 * @return {string} 37 * @return {string}
35 */ 38 */
36 WebInspector.UIString = function(string, vararg) { 39 Common.UIString = function(string, vararg) {
37 return String.vsprintf(WebInspector.localize(string), Array.prototype.slice.ca ll(arguments, 1)); 40 return String.vsprintf(Common.localize(string), Array.prototype.slice.call(arg uments, 1));
38 }; 41 };
39 42
40 /** 43 /**
41 * @param {string} string 44 * @param {string} string
42 * @param {...*} vararg 45 * @param {...*} vararg
43 * @return {string} 46 * @return {string}
44 */ 47 */
45 WebInspector.UIString.capitalize = function(string, vararg) { 48 Common.UIString.capitalize = function(string, vararg) {
46 if (WebInspector._useLowerCaseMenuTitles === undefined) 49 if (Common._useLowerCaseMenuTitles === undefined)
47 throw 'WebInspector.setLocalizationPlatform() has not been called'; 50 throw 'Common.setLocalizationPlatform() has not been called';
48 51
49 var localized = WebInspector.localize(string); 52 var localized = Common.localize(string);
50 var capitalized; 53 var capitalized;
51 if (WebInspector._useLowerCaseMenuTitles) 54 if (Common._useLowerCaseMenuTitles)
52 capitalized = localized.replace(/\^(.)/g, '$1'); 55 capitalized = localized.replace(/\^(.)/g, '$1');
53 else 56 else
54 capitalized = localized.replace(/\^(.)/g, function(str, char) { 57 capitalized = localized.replace(/\^(.)/g, function(str, char) {
55 return char.toUpperCase(); 58 return char.toUpperCase();
56 }); 59 });
57 return String.vsprintf(capitalized, Array.prototype.slice.call(arguments, 1)); 60 return String.vsprintf(capitalized, Array.prototype.slice.call(arguments, 1));
58 }; 61 };
59 62
60 /** 63 /**
61 * @param {string} platform 64 * @param {string} platform
62 */ 65 */
63 WebInspector.setLocalizationPlatform = function(platform) { 66 Common.setLocalizationPlatform = function(platform) {
64 WebInspector._useLowerCaseMenuTitles = platform === 'windows'; 67 Common._useLowerCaseMenuTitles = platform === 'windows';
65 }; 68 };
66 69
67 /** 70 /**
68 * @param {string} string 71 * @param {string} string
69 * @return {string} 72 * @return {string}
70 */ 73 */
71 WebInspector.localize = function(string) { 74 Common.localize = function(string) {
72 return string; 75 return string;
73 }; 76 };
74 77
75 /** 78 /**
76 * @unrestricted 79 * @unrestricted
77 */ 80 */
78 WebInspector.UIStringFormat = class { 81 Common.UIStringFormat = class {
79 /** 82 /**
80 * @param {string} format 83 * @param {string} format
81 */ 84 */
82 constructor(format) { 85 constructor(format) {
83 /** @type {string} */ 86 /** @type {string} */
84 this._localizedFormat = WebInspector.localize(format); 87 this._localizedFormat = Common.localize(format);
85 /** @type {!Array.<!Object>} */ 88 /** @type {!Array.<!Object>} */
86 this._tokenizedFormat = String.tokenizeFormatString(this._localizedFormat, S tring.standardFormatters); 89 this._tokenizedFormat = String.tokenizeFormatString(this._localizedFormat, S tring.standardFormatters);
87 } 90 }
88 91
89 /** 92 /**
90 * @param {string} a 93 * @param {string} a
91 * @param {string} b 94 * @param {string} b
92 * @return {string} 95 * @return {string}
93 */ 96 */
94 static _append(a, b) { 97 static _append(a, b) {
95 return a + b; 98 return a + b;
96 } 99 }
97 100
98 /** 101 /**
99 * @param {...*} vararg 102 * @param {...*} vararg
100 * @return {string} 103 * @return {string}
101 */ 104 */
102 format(vararg) { 105 format(vararg) {
103 return String 106 return String
104 .format( 107 .format(
105 this._localizedFormat, arguments, String.standardFormatters, '', Web Inspector.UIStringFormat._append, 108 this._localizedFormat, arguments, String.standardFormatters, '', Com mon.UIStringFormat._append,
106 this._tokenizedFormat) 109 this._tokenizedFormat)
107 .formattedResult; 110 .formattedResult;
108 } 111 }
109 }; 112 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698