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

Side by Side Diff: chrome/tools/test/reference_build/chrome_linux/resources/bookmark_manager/js/localstrings.js

Issue 877003: Updating the Chromium reference build on Linux. The continuous build... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 9 months 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 | Annotate | Revision Log
Property Changes:
Name: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009-2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // TODO(arv): Namespace and share code with DOMUI
6
7 /**
8 * The local strings get injected into the page usig a varaible named
9 * {@code templateData}. This class provides a simpler interface to access those
10 * strings.
11 * @constructor
12 */
13 function LocalStrings() {
14 }
15
16 LocalStrings.prototype = {
17
18 /**
19 * The template data object.
20 * @type {Object}
21 */
22 templateData: null,
23
24 /**
25 * Gets a localized string by its id.
26 * @param {string} s The id of the string we want.
27 * @return {string} The localized string.
28 */
29 getString: function(id) {
30 return this.templateData[id] || '';
31 },
32
33 /**
34 * Returns a formatted localized string where all %s contents are replaced
35 * by the second argument and where $1 to $9 are replaced by the second to
36 * tenths arguments.
37 * @param {string} id The ID of the string we want.
38 * @param {string} v The string to include in the formatted string.
39 * @param {...string} The extra values to include in the fomatted output.
40 * @return {string} The formatted string.
41 */
42 getStringF: function(id, v, var_args) {
43 // The localized messages should contain $n but they also use %s from time
44 // to time so we support both until all the messages have been unified.
45 var s = this.getString(id);
46 var args = arguments;
47 return s.replace(/%s|\$[$1-9]/g, function(m) {
48 if (m == '%s')
49 return v;
50 if (m == '$$')
51 return '$';
52 return args[m[1]];
53 });
54 }
55 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698