i18n.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *|
  5. *| IBM Cognos Products: BUX
  6. *|
  7. *| (C) Copyright IBM Corp. 2014
  8. *|
  9. *| US Government Users Restricted Rights - Use, duplication or
  10. *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  11. *|
  12. *+------------------------------------------------------------------------+
  13. */
  14. /*global define,require,window,icdConfig,console*/
  15. define("pd/i18n", ["dojo/_base/lang"],
  16. function(lang) {
  17. var a = icdConfig.productLocale.split("-"), aLocales = [""], sPreviousLocale = "", i=0;
  18. // split locale code, following the Dojo way. If we get ab-cd-ef as a locale, we will use:
  19. // buxuimsg, buxuimsg_ab, buxuimsg_ab-cd, buxuimsg_ab-cd-ef
  20. for (i = 0; i < a.length; i++) {
  21. var l = sPreviousLocale + a[i];
  22. aLocales.push("_"+l);
  23. sPreviousLocale = l + (l?"-":"");
  24. }
  25. // Initialize our Global object for i18n strings.
  26. window.PDMSG={};
  27. var sWebContent = (icdConfig.WebContentURL||icdConfig.ThemeFolder+"/../../.."); // Use WebContent from icdConfig. It can be empty in DOH tests, so set a backup using the ThemeFolder.
  28. // Merge in all locales files into window.PDMSG
  29. for (i = 0; i < aLocales.length; i++) {
  30. var loc = aLocales[i];
  31. try {
  32. var oMsgs = eval( require.getText(sWebContent + "/ps/lobdata/dojo/pd/nls/pduimsg" + loc + ".js") );
  33. // PDMSG is divided in sections, we need to merge each section separately because mixin() isn't doing a deep copy.
  34. for (var j in oMsgs) {
  35. window.PDMSG[j] = lang.mixin( window.PDMSG[j]||{}, oMsgs[j] );
  36. }
  37. } catch(e) {
  38. console.debug(e);
  39. }
  40. }
  41. return window.PDMSG;
  42. });