StringResourcesBridge.js 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * Licensed Materials - Property of IBM
  3. * IBM Cognos Products: Modeling UI (C) Copyright IBM Corp. 2017
  4. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  5. */
  6. define([
  7. 'i18n!./nls/ModellerResources', 'polyglot'
  8. ], function(resources, Polyglot) {
  9. var StringResourcesBridge = function() {
  10. this._polyglot = new Polyglot({phrases: resources});
  11. };
  12. /**
  13. * Get the string resource for the given key and interpolation options
  14. *
  15. * @param key The key of the string to return
  16. * @param interpolationOptions Optional interpolation options (see poly.t documentation for details)
  17. * @returns The string to display
  18. */
  19. StringResourcesBridge.prototype.get = function(key, interpolationOptions) {
  20. var translated = this._polyglot.t(key, interpolationOptions);
  21. if (this._polyglot.phrases[key] === undefined) {
  22. translated = "__NOT_TRANSLATED__(" + key + ")";
  23. }
  24. return translated;
  25. };
  26. return new StringResourcesBridge();
  27. });