1
0

languageService.js 1018 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import Lexers from './../../grammar/';
  2. import line_i18n from 'line-i18n';
  3. // This is for LanguageService with localStorage
  4. const DEFAULT_LANG = "pt";
  5. class LanguageServiceExtended extends line_i18n.LanguageServiceNoLS {
  6. constructor () {
  7. super(DEFAULT_LANG);
  8. }
  9. getCurrentLexer () {
  10. const langInfo = Lexers[this.getLang()];
  11. if(langInfo === null || langInfo === undefined) {
  12. return Lexers[this.getDefaultLang()].lexer;
  13. } else {
  14. return langInfo.lexer;
  15. }
  16. }
  17. getCurrentLangFuncs () {
  18. const langInfo = Lexers[this.getLang()];
  19. if(langInfo === null || langInfo === undefined) {
  20. return Lexers[this.getDefaultLang()].langFuncs;
  21. } else {
  22. return langInfo.langFuncs;
  23. }
  24. }
  25. getCurrentLangLibs () {
  26. const langInfo = Lexers[this.getLang()];
  27. if(langInfo === null || langInfo === undefined) {
  28. return Lexers[this.getDefaultLang()].langLibs;
  29. }
  30. return langInfo.langLibs;
  31. }
  32. }
  33. export const LanguageService = new LanguageServiceExtended();