languageService.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* global iLMparameters*/
  2. import Lexers from "./../../grammar/";
  3. import line_i18n from "line-i18n";
  4. import { Config } from "./../util/config";
  5. class LanguageServiceExtended extends line_i18n.LanguageServiceNoLS {
  6. constructor () {
  7. super(
  8. typeof iLMparameters === "undefined"
  9. ? Config.default_lang
  10. : iLMparameters.lang
  11. );
  12. }
  13. getDefaultLang () {
  14. return "en";
  15. }
  16. getCurrentLexer () {
  17. const langInfo = Lexers[this.getLang()];
  18. if (langInfo === null || langInfo === undefined) {
  19. return Lexers[this.getDefaultLang()].lexer;
  20. } else {
  21. return langInfo.lexer;
  22. }
  23. }
  24. getCurrentLangFuncs () {
  25. const langInfo = Lexers[this.getLang()];
  26. if (langInfo === null || langInfo === undefined) {
  27. return Lexers[this.getDefaultLang()].langFuncs;
  28. } else {
  29. return langInfo.langFuncs;
  30. }
  31. }
  32. getCurrentLangLibs () {
  33. const langInfo = Lexers[this.getLang()];
  34. if (langInfo === null || langInfo === undefined) {
  35. return Lexers[this.getDefaultLang()].langLibs;
  36. }
  37. return langInfo.langLibs;
  38. }
  39. }
  40. export const LanguageService = new LanguageServiceExtended();