Skip to content

Commit

Permalink
fix translations. issue #122
Browse files Browse the repository at this point in the history
  • Loading branch information
edutra committed Dec 4, 2018
1 parent 9d0a112 commit d00b51f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 22 deletions.
19 changes: 9 additions & 10 deletions client/godonnie/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,12 @@ int ExprTreeEvaluator::run(pANTLR3_BASE_TREE tree)
locale loc = gen(string(getenv("DONNIE_LANG")) + ".UTF-8");
locale::global(loc);
cout.imbue(loc);

pANTLR3_COMMON_TOKEN tok = tree->getToken(tree);
string crash_str = translate("bateu");
string ncrash_str = translate("não bateu");

std::ostringstream sayStr;
pANTLR3_COMMON_TOKEN tok = tree->getToken(tree);

//printf("%d", tok->type);
if(tok) {
switch(tok->type) {
Expand Down Expand Up @@ -450,7 +450,7 @@ int ExprTreeEvaluator::run(pANTLR3_BASE_TREE tree)
#endif
break;
}

case POS:
{
int arg;
Expand Down Expand Up @@ -497,7 +497,8 @@ int ExprTreeEvaluator::run(pANTLR3_BASE_TREE tree)
//throw sintaxeException("Sintaxe não conhecida para comando '"+tokens[0]+"'\n");

arg = Donnie->color_to_value(tokens[1]);
if(arg == 0xFFFFFFFF)
//cout << arg << endl;
if(arg == -1)
throw sintaxeException(string(translate("Sintaxe não conhecida para comando '"))+tokens[0]+"'\n");

// only report when there are blobs with the selected color
Expand Down Expand Up @@ -726,27 +727,25 @@ int ExprTreeEvaluator::run(pANTLR3_BASE_TREE tree)

case PROCINV:
{

char* name = (char*)getText(getChild(tree,0));
mem local; // Inicia dicionário local

procDec procedure = DonnieMemory::getInstance()->getProc(name);

if(procedure.argNum == tree->getChildCount(tree)-1)
{

for (int f = 1; f <= procedure.argNum ; f++)
local.memory[procedure.args[f-1]] = run(getChild(tree,f)); // Atribui as variaveis de argumento no dicionário

DonnieMemory::getInstance()->stackMemory(local); // Empilha dicionário

run(procedure.node); // Executa procedimento

DonnieMemory::getInstance()->unstackMemory(); // Desempilha dicionário
DonnieMemory::getInstance()->unstackMemory();
}
else
{
sayStr << translate("Número de argumentos invalido.");
Donnie->speak(sayStr.str());
cout << sayStr.str() << endl;

}

Expand Down Expand Up @@ -802,7 +801,7 @@ int ExprTreeEvaluator::run(pANTLR3_BASE_TREE tree)
"," << Donnie->GetPos("body",2) << "]"; //POSITION_YAW in degrees
// dont add newline here !
}

//cout << output.str() << endl;
Donnie->speak(output.str());
break;
Expand Down
14 changes: 4 additions & 10 deletions client/godonnie/DonnieClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ const double SIDE_RANGER = 0.05;
const double FRONT_RANGER = 0.06;
const double BACK_RANGER = 0.05;

#ifndef LANG
#define LANG "pt-br"
#endif

//Singleton. init pointer withou allocations
DonnieClient *DonnieClient::singleton = NULL;
Expand Down Expand Up @@ -128,7 +125,6 @@ string DonnieClient::value_to_color(int color_value)
string color;
ostringstream oss;
unsigned int file_value;

ifstream file;
string donnie_path = GetEnv("DONNIE_PATH");

Expand Down Expand Up @@ -184,22 +180,22 @@ int DonnieClient::color_to_value(string input_color)
string color;
ostringstream oss;
unsigned int file_value;

string lang = GetEnv("DONNIE_LANG");
// Set up language environment
generator gen;
gen.add_messages_path(string(GetEnv("DONNIE_PATH")) + "/resources/loc");
gen.add_messages_domain("DonnieClient");
locale loc = gen(string(GetEnv("DONNIE_LANG")) + ".UTF-8");
locale loc = gen(lang + ".UTF-8");
locale::global(loc);
cout.imbue(loc);
cerr.imbue(loc);

string donnie_path = GetEnv("DONNIE_PATH");

// read the color file according to the language
if(LANG == "pt-br")
if(lang == "pt_BR")
donnie_path = donnie_path + "/resources/color_files/rgb-pt-br.txt";
else if (LANG == "eng")
else if (lang == "en_US")
donnie_path = donnie_path + "/resources/color_files/rgb-en.txt";
else
donnie_path = donnie_path + "/resources/color_files/rgb-pt-br.txt";
Expand All @@ -216,7 +212,6 @@ int DonnieClient::color_to_value(string input_color)
str_buff >> file_value;
getline(file,color, '\n');


if(input_color == color)
return file_value;
}
Expand Down Expand Up @@ -1134,4 +1129,3 @@ void DonnieClient::vibrate(int idx, char val)
else
speak(string(translate("O cinto deve ser ligado")));
}

4 changes: 2 additions & 2 deletions client/godonnie/GoDonnie.g
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,8 @@ POS : (('P'|'p')('O'|'o')('S'|'s')
//|((('P'|'p')('O'|'o')('S'|'s')('I'|'i')('Ç'|'ç'|'C'|'c')('Ã'|'ã'|'A'|'a')('O'|'o'))?) ((' ')+ (('X'|'x') | ('Y'|'y') | ('A'|'a')))?
;
COLOR : (('C'|'c')('O'|'o')('R'|'r')) (' ')+ ((('A'|'a')('Z'|'z')('U'|'u')('L'|'l')) | (('V'|'v')('E'|'e')('R'|'r')('D'|'d')('E'|'e')) | (('V'|'v')('E'|'e')('R'|'r')('M'|'m')('E'|'e')('L'|'l')('H'|'h')('O'|'o')))
|(('C'|'c')('O'|'o')('L'|'l')('O'|'o')('R'|'r')) (' ')+ ((('B'|'b')('L'|'l')('U'|'u')('E'|'e')) | (('G'|'g')('R'|'r')('E'|'e')('N'|'n')) | (('R'|'r')('E'|'e')('D'|'d')))
COLOR : ((('C'|'c')('O'|'o')('R'|'r')) (' ')+ ((('A'|'a')('Z'|'z')('U'|'u')('L'|'l')) | (('V'|'v')('E'|'e')('R'|'r')('D'|'d')('E'|'e')) | (('V'|'v')('E'|'e')('R'|'r')('M'|'m')('E'|'e')('L'|'l')('H'|'h')('O'|'o'))))
|((('C'|'c')('O'|'o')('L'|'l')('O'|'o')('R'|'r')) (' ')+ ((('B'|'b')('L'|'l')('U'|'u')('E'|'e')) | (('G'|'g')('R'|'r')('E'|'e')('E'|'e')('N'|'n')) | (('R'|'r')('E'|'e')('D'|'d'))))
;
SOUND : (('S'|'s')('O'|'o')('M'|'m')) (' ')+ ((('L'|'l')('I'|'i')('G'|'g')('A'|'a')('D'|'d')('O'|'o')) | (('D'|'d')('E'|'e')('S'|'s')('L'|'l')('I'|'i')('G'|'g')('A'|'a')('D'|'d')('O'|'o')))
Expand Down

0 comments on commit d00b51f

Please sign in to comment.