1
0

localizedStringsService.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { LanguageService } from "./languageService";
  2. import line_i18n from 'line-i18n';
  3. import Langs from './../../i18n';
  4. class IVProgLocalizedStrings extends line_i18n.LocalizedStrings {
  5. constructor(langService, langsJsons, shouldListenToChange = false) {
  6. super(langService, langsJsons, shouldListenToChange);
  7. }
  8. translateType (type, dim) {
  9. switch (dim) {
  10. case 0:
  11. return this.getUI(type);
  12. default:
  13. const transType = this.getUI(type);
  14. if(dim === 1)
  15. return this.getUI("vector_string", [transType])
  16. else
  17. return this.getUI("matrix_string", [transType])
  18. }
  19. }
  20. translateOp (op) {
  21. switch(op.ord) {
  22. case Operators.AND.ord:
  23. case Operators.OR.ord:
  24. case Operators.NOT.ord:
  25. return this.getUI(op.value);
  26. default:
  27. return op.value;
  28. }
  29. }
  30. }
  31. export const LocalizedStrings = Object.freeze(new IVProgLocalizedStrings(LanguageService, Langs, true));
  32. let _instance = null;
  33. export function getInstance () {
  34. if(_instance == null) {
  35. _instance = new IVProgLocalizedStrings(LanguageService, Langs);
  36. }
  37. return _instance;
  38. }