StringResource.js 935 B

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * Licensed Materials - Property of IBM
  3. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2018
  4. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  5. */
  6. import resources from 'amdi18n-loader!./NotebookResources';
  7. const Polyglot = require('polyglot');
  8. class StringResources {
  9. constructor() {
  10. /**
  11. * Module which provides simple access to string resources.
  12. */
  13. this.polyglot = new Polyglot({
  14. phrases: resources
  15. });
  16. }
  17. /**
  18. * Get the string resource for the given key and interpolation options
  19. *
  20. * @param key The key of the string to return
  21. * @param interpolationOptions Optional interpolation options (see poly.t documentation for details)
  22. * @returns The string to display
  23. */
  24. get(key, interpolationOptions) {
  25. return this.polyglot.t(key, interpolationOptions);
  26. }
  27. }
  28. export default new StringResources();