Browse Source

Implement english as default language

Disable spanish language for the grammar and UI
Lucas de Souza 3 years ago
parent
commit
15a423d849
9 changed files with 928 additions and 950 deletions
  1. 4 4
      grammar/en/ivprog.g4
  2. 13 13
      grammar/index.js
  3. 2 2
      i18n/error.csv
  4. 1 1
      i18n/message.csv
  5. 1 1
      i18n/ui.csv
  6. 13 9
      js/services/languageService.js
  7. 11 12
      js/services/localizedStringsService.js
  8. 870 895
      package-lock.json
  9. 13 13
      package.json

+ 4 - 4
grammar/en/ivprog.g4

@@ -27,7 +27,7 @@ RK_INTEGER
 
 RK_CHARACTER
   : 'char'
-  ;    
+  ;
 
 RK_SWITCH
   : 'switch'
@@ -51,7 +51,7 @@ RK_FUNCTION
 
 RK_RETURN
   : 'return'
-  ;  
+  ;
 
 RK_FOR
   : 'for'
@@ -215,7 +215,7 @@ fragment ExponentPart
 STRING
   : '"' STRING_CHARACTER* '"'
   ;
-    
+
 fragment STRING_CHARACTER //String as defined at https://github.com/antlr/grammars-v4/blob/master/java8/Java8.g4
   : ~["\\\r\n]
   | ESC_SEQ
@@ -225,7 +225,7 @@ CHARACTER //Character as defined at https://github.com/antlr/grammars-v4/blob/ma
   : '\'' ( ESC_SEQ | ~['\\\r\n]) '\''
   ;
 
-WHITESPACE 
+WHITESPACE
   : ( ' ' | '\t') -> skip
   ;
 

+ 13 - 13
grammar/index.js

@@ -1,15 +1,15 @@
-import * as PT from './pt/ivprog.g4';
-import PTFuncs from './pt/langFunctions';
-import PTLibs from './pt/langLibs';
-import * as EN from './en/ivprog.g4';
-import ENFuncs from './en/langFunctions';
-import ENLibs from './en/langLibs';
-import * as ES from './es/ivprog.g4';
-import ESFuncs from './es/langFunctions';
-import ESLibs from './es/langLibs';
+import * as PT from "./pt/ivprog.g4";
+import PTFuncs from "./pt/langFunctions";
+import PTLibs from "./pt/langLibs";
+import * as EN from "./en/ivprog.g4";
+import ENFuncs from "./en/langFunctions";
+import ENLibs from "./en/langLibs";
+/*import * as ES from "./es/ivprog.g4";
+import ESFuncs from "./es/langFunctions";
+import ESLibs from "./es/langLibs";*/
 
 export default {
-  pt: {lexer: PT.ivprog, langFuncs: PTFuncs, langLibs: PTLibs},
-  en: {lexer: EN.ivprog, langFuncs: ENFuncs, langLibs: ENLibs},
-  es: {lexer: ES.ivprog, langFuncs: ESFuncs, langLibs: ESLibs}
-}
+  pt: { lexer: PT.ivprog, langFuncs: PTFuncs, langLibs: PTLibs },
+  en: { lexer: EN.ivprog, langFuncs: ENFuncs, langLibs: ENLibs },
+  //es: {lexer: ES.ivprog, langFuncs: ESFuncs, langLibs: ESLibs}
+};

+ 2 - 2
i18n/error.csv

@@ -1,4 +1,4 @@
-id,pt,en,es
+id,pt,en,_disabled_es
 token_missing_one,"Erro de sintaxe: Espera-se $0, mas encontrou-se $1 na linha:$2, coluna:$3","Syntax error: Expected $0 but found $1 at line:$2, column:$3"," "
 token_missing_two,"Erro de sintaxe: Esperava-se $0 ou $1 mas encontrou-se $2 na liha:$3, coluna: $4","Syntax error: Expected $0 or $1 but found $2 at line:$3, column: $4"," "
 eos_missing,"Falta uma nova linha ou ; na linha: $0, coluna: $1","A new line or a ‘;’ is missing at line: $0, column: $1"," "
@@ -133,4 +133,4 @@ invalid_for_variable,Erro na linha $0: A variavel $1 utilizada no comando repita
 invalid_for_from,Erro na linha $0: O valor $1 passado para o parâmetro 'de' do comando repita_para deve ser do tipo inteiro.,Error at line $0: The value $1 passed to the parameter 'from' of the repeat_for command must be of type int.,
 invalid_for_to,Erro na linha $0: O valor $1 passado para o parâmetro 'para' do comando repita_para deve ser do tipo inteiro.,Error at line $0: The value $1 passed to the parameter 'to' of the repeat_for command must be of type int.,
 invalid_for_pass,Erro na linha $0: O valor $1 passado para o parâmetro 'passo' do comando repita_para deve ser do tipo inteiro.,Error at line $0: The value $1 passed to the parameter 'pass' of the repeat_for command must be of type int.,
-exceed_max_instructions,Número de instruções excedeu o limite definido. Certifique-se que seu código não possui laços infinitos ou muitas chamadas de funções recursivas.,The number of instructions executed by your program exceed the defined limit. Check your code for infinite loops or excessive recursive functions calls.,
+exceed_max_instructions,Número de instruções excedeu o limite definido. Certifique-se que seu código não possui laços infinitos ou muitas chamadas de funções recursivas.,The number of instructions executed by your program exceed the defined limit. Check your code for infinite loops or excessive recursive functions calls.,

+ 1 - 1
i18n/message.csv

@@ -1,4 +1,4 @@
-id,pt,en,es
+id,pt,en,_disabled_es
 test_case_success,"<div class='assessment-div-detail' onClick='ivprogCore.openAssessmentDetail(event)' data-page=""$1""><span>Caso de teste $0</span>: OK</div>","<div class='assessment-div-detail' onClick='ivprogCore.openAssessmentDetail(event)' data-page=""$1""><span>Test case $0</span>: OK</div>"," "
 test_case_duration,Levou $0ms,Took $0ms," "
 test_suite_grade,A sua solução alcançou $0% da nota.,Your solution scored $0% of the grade.," "

+ 1 - 1
i18n/ui.csv

@@ -1,4 +1,4 @@
-id,pt,en,es
+id,pt,en,_disabled_es
 function,funcao,function,funccion
 btn_clear,Limpar,Clean,
 btn_function,Função,Function,

+ 13 - 9
js/services/languageService.js

@@ -1,20 +1,24 @@
-import Lexers from './../../grammar/';
-import line_i18n from 'line-i18n';
+/* global iLMparameters*/
+import Lexers from "./../../grammar/";
+import line_i18n from "line-i18n";
 import { Config } from "./../util/config";
 
 class LanguageServiceExtended extends line_i18n.LanguageServiceNoLS {
-
   constructor () {
-    super(typeof(iLMparameters) === 'undefined' ? Config.default_lang : iLMparameters.lang);
+    super(
+      typeof iLMparameters === "undefined"
+        ? Config.default_lang
+        : iLMparameters.lang
+    );
   }
 
   getDefaultLang () {
-    return "pt";
+    return "en";
   }
 
   getCurrentLexer () {
     const langInfo = Lexers[this.getLang()];
-    if(langInfo === null || langInfo === undefined) {
+    if (langInfo === null || langInfo === undefined) {
       return Lexers[this.getDefaultLang()].lexer;
     } else {
       return langInfo.lexer;
@@ -23,7 +27,7 @@ class LanguageServiceExtended extends line_i18n.LanguageServiceNoLS {
 
   getCurrentLangFuncs () {
     const langInfo = Lexers[this.getLang()];
-    if(langInfo === null || langInfo === undefined) {
+    if (langInfo === null || langInfo === undefined) {
       return Lexers[this.getDefaultLang()].langFuncs;
     } else {
       return langInfo.langFuncs;
@@ -32,11 +36,11 @@ class LanguageServiceExtended extends line_i18n.LanguageServiceNoLS {
 
   getCurrentLangLibs () {
     const langInfo = Lexers[this.getLang()];
-    if(langInfo === null || langInfo === undefined) {
+    if (langInfo === null || langInfo === undefined) {
       return Lexers[this.getDefaultLang()].langLibs;
     }
     return langInfo.langLibs;
   }
 }
 
-export const LanguageService  = new LanguageServiceExtended();
+export const LanguageService = new LanguageServiceExtended();

+ 11 - 12
js/services/localizedStringsService.js

@@ -1,12 +1,11 @@
-import line_i18n from 'line-i18n';
+import line_i18n from "line-i18n";
 import { LanguageService } from "./languageService";
 import { LanguageDefinedFunction } from "./../processor/definedFunctions";
-import Langs from './../../i18n';
+import Langs from "./../../i18n";
 import { Operators } from "./../ast/operators";
 
 class IVProgLocalizedStrings extends line_i18n.LocalizedStrings {
-
-  constructor(langService, langsJsons, shouldListenToChange =  false) {
+  constructor (langService, langsJsons, shouldListenToChange = false) {
     super(langService, langsJsons, shouldListenToChange);
   }
 
@@ -16,15 +15,13 @@ class IVProgLocalizedStrings extends line_i18n.LocalizedStrings {
       case 0:
         return type_string;
       default:
-        if(dim > 1)
-          return this.getUI("matrix_info_string", [type_string])
-        else
-          return this.getUI("vector_info_string", [type_string])
+        if (dim > 1) return this.getUI("matrix_info_string", [type_string]);
+        else return this.getUI("vector_info_string", [type_string]);
     }
   }
-  
+
   translateOp (op) {
-    switch(op.ord) {
+    switch (op.ord) {
       case Operators.AND.ord:
       case Operators.OR.ord:
       case Operators.NOT.ord:
@@ -43,12 +40,14 @@ class IVProgLocalizedStrings extends line_i18n.LocalizedStrings {
   }
 }
 
-export const LocalizedStrings = Object.freeze(new IVProgLocalizedStrings(LanguageService, Langs, true));
+export const LocalizedStrings = Object.freeze(
+  new IVProgLocalizedStrings(LanguageService, Langs, true)
+);
 
 let _instance = null;
 
 export function getInstance () {
-  if(_instance == null) {
+  if (_instance == null) {
     _instance = new IVProgLocalizedStrings(LanguageService, Langs);
   }
   return _instance;

File diff suppressed because it is too large
+ 870 - 895
package-lock.json


+ 13 - 13
package.json

@@ -26,28 +26,28 @@
   },
   "homepage": "https://git.lcalion.com/ivprog#readme",
   "devDependencies": {
-    "@babel/core": "^7.6.2",
-    "@babel/plugin-transform-runtime": "^7.9.0",
-    "@babel/preset-env": "^7.6.2",
-    "@typescript-eslint/eslint-plugin": "^2.3.2",
-    "@typescript-eslint/parser": "^2.3.2",
+    "@babel/core": "^7.10.2",
+    "@babel/plugin-transform-runtime": "^7.10.1",
+    "@babel/preset-env": "^7.10.2",
+    "@typescript-eslint/eslint-plugin": "^2.34.0",
+    "@typescript-eslint/parser": "^2.34.0",
     "antlr4-webpack-loader": "*",
     "babel-loader": "^8.0.6",
     "clean-webpack-plugin": "3.x",
     "copy-webpack-plugin": "^5.1.1",
+    "csv-parser": "^2.3.3",
     "eslint": "^6.5.1",
-    "html-webpack-plugin": "^4.2",
-    "server": "^1.0.19",
+    "html-webpack-plugin": "^4.3.0",
+    "server": "^1.0.29",
     "ts-loader": "^5.4.5",
-    "typescript": "^3.8.3",
-    "webpack": "4.x",
-    "webpack-cli": "3.x",
-    "csv-parser": "^2.3.1"
+    "typescript": "^3.9.5",
+    "webpack": "^4.43.0",
+    "webpack-cli": "3.x"
   },
   "dependencies": {
-    "@babel/runtime": "^7.9.2",
+    "@babel/runtime": "^7.10.2",
     "antlr4": "^4.7.2",
-    "codemirror": "^5.49.0",
+    "codemirror": "^5.54.0",
     "decimal.js": "^10.2.0",
     "line-i18n": "git+http://200.144.254.107/git/LInE/line-i18n.git",
     "melanke-watchjs": "^1.5.0"