UIString.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright (C) 2011 Google Inc. All rights reserved.
  3. * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
  4. * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).
  5. * Copyright (C) 2009 Joseph Pecoraro
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
  17. * its contributors may be used to endorse or promote products derived
  18. * from this software without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
  21. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  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
  24. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  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
  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
  29. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. /**
  32. * @param {string} string
  33. * @param {...*} vararg
  34. * @return {string}
  35. */
  36. WebInspector.UIString = function(string, vararg)
  37. {
  38. if (Preferences.localizeUI) {
  39. if (window.localizedStrings && string in window.localizedStrings)
  40. string = window.localizedStrings[string];
  41. else {
  42. if (!(string in WebInspector._missingLocalizedStrings)) {
  43. console.warn("Localized string \"" + string + "\" not found.");
  44. WebInspector._missingLocalizedStrings[string] = true;
  45. }
  46. if (Preferences.showMissingLocalizedStrings)
  47. string += " (not localized)";
  48. }
  49. }
  50. return String.vsprintf(string, Array.prototype.slice.call(arguments, 1));
  51. }
  52. WebInspector._missingLocalizedStrings = {};