languageService.js 684 B

1234567891011121314151617181920212223242526272829
  1. import Lexers from './../../grammar/';
  2. const DEFAULT_LANG = "pt";
  3. export const LanguageService = Object.freeze({
  4. getLang: () => {
  5. const lang = localStorage.getItem('ivprog.lang');
  6. if (lang === null || lang === undefined) {
  7. console.warn("Internal Error. User language information has not been set. Returning default...");
  8. return LanguageService.getDefaultLang();
  9. }
  10. return lang;
  11. },
  12. getDefaultLang: () => {
  13. return DEFAULT_LANG;
  14. },
  15. getCurrentLexer: () => {
  16. const lexer = Lexers[LanguageService.getLang()];
  17. if(lexer === null || lexer === undefined) {
  18. return Lexers[DEFAULT_LANG];
  19. } else {
  20. return lexer;
  21. }
  22. }
  23. });