APIs

Show:
  1. /**
  2. * Library for the flexygo.localization.
  3. *
  4. * @class flexygo.localization
  5. */
  6. var flexygo;
  7. (function (flexygo) {
  8. var localization;
  9. (function (localization) {
  10. /**
  11. * Translates java script strings to profile default language.
  12. * If no translation is found it will display fall back language en-gb
  13. * @method translate
  14. * @param {string} key - language variable string.
  15. * @return {string} - returns translated string
  16. */
  17. function translate(key) {
  18. var text = null;
  19. try {
  20. text = key.split('.').reduce((object, index) => object ? object[index] : null, flexygo.culture[flexygo.profiles.langKey.toLowerCase()]);
  21. }
  22. catch (ex) { }
  23. if (text == null) {
  24. try {
  25. text = key.split('.').reduce((object, index) => object ? object[index] : null, flexygo.culture.engb);
  26. }
  27. catch (ex) { }
  28. }
  29. if (text == null) {
  30. text = key;
  31. }
  32. return text;
  33. }
  34. localization.translate = translate;
  35. /**
  36. * Initializes date plugin moment.locale with correct language.
  37. * @method init
  38. */
  39. function init() {
  40. if (navigator && navigator.language) {
  41. moment.locale(navigator.language);
  42. }
  43. else {
  44. moment.locale('es');
  45. }
  46. }
  47. localization.init = init;
  48. })(localization = flexygo.localization || (flexygo.localization = {}));
  49. })(flexygo || (flexygo = {}));
  50. //# sourceMappingURL=translate.js.map