Implementar systema de idiomas con gl, es y en
Signed-off-by: somebody_master <somebody_master@somebodyserver.mooo.com>
This commit is contained in:
34
src/main.cpp
34
src/main.cpp
@ -1,7 +1,8 @@
|
||||
#include "configFile.hpp"
|
||||
#include "ui.hpp"
|
||||
#include <locale.h>
|
||||
#include <thread>
|
||||
#include "configFile.hpp"
|
||||
#include "ui.hpp"
|
||||
#include "textos.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -37,8 +38,10 @@ void showMenu(vector<string> *menu_elems, const int8_t *num_menu, vector<string>
|
||||
void showMenu(vector<string> *menu_elems, const int8_t *num_menu, Config *config);
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
// locale::global(locale("es_ES.utf8"));
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
string idioma = setlocale(LC_ALL, "");
|
||||
txt::inicializarIdioma(idioma);
|
||||
|
||||
if (ui::initUI(&MENU_PRINCIPAL, &MENU_ERROR) != 0) {
|
||||
return -1;
|
||||
}
|
||||
@ -48,7 +51,6 @@ int main(int argc, char *argv[]) {
|
||||
if (config.getTiempo() == "") {
|
||||
userInterface(&PRIMER_INICIO, &config);
|
||||
} else {
|
||||
|
||||
userInterface(&MENU_PRINCIPAL, &config);
|
||||
}
|
||||
|
||||
@ -65,7 +67,7 @@ void userInterface(const int8_t *num_menu, vector<string> *mensaje, Config *conf
|
||||
switch (*num_menu) {
|
||||
case CONFIGURAR_MENU_PRINCIPAL:
|
||||
case MENU_PRINCIPAL: {
|
||||
vector<string> elem_menu = {"- Iniciar Stress Test", "- Configurar", "- Salir"};
|
||||
vector<string> elem_menu = {txt::g_menuPrincipal_1, txt::g_menuPrincipal_2, txt::g_menuPrincipal_3};
|
||||
showMenu(&elem_menu, &MENU_PRINCIPAL, mensaje, config);
|
||||
break;
|
||||
}
|
||||
@ -75,7 +77,7 @@ void userInterface(const int8_t *num_menu, vector<string> *mensaje, Config *conf
|
||||
}
|
||||
|
||||
case MENU_CONFIGURACION: {
|
||||
vector<string> elem_menu = {"- Configurar todo", "- Número de hilos", "- Tiempo", "- Menú principal"};
|
||||
vector<string> elem_menu = {txt::g_menuConfigurar_1, txt::g_menuConfigurar_2, txt::g_menuConfigurar_3, txt::g_menuConfigurar_4};
|
||||
showMenu(&elem_menu, num_menu, mensaje, config);
|
||||
break;
|
||||
}
|
||||
@ -83,8 +85,8 @@ void userInterface(const int8_t *num_menu, vector<string> *mensaje, Config *conf
|
||||
case CONFIGURAR_TODO:
|
||||
case PRIMER_INICIO: {
|
||||
|
||||
vector<string> textos_init = {"Toda la configuración se escribirá en " + cf::g_configFile, "", ""};
|
||||
vector<string> elemens = {"- Número de hilos\t> ", "- Tiempo de ejecución\t> "};
|
||||
vector<string> textos_init = {txt::g_confTodo + cf::g_configFile, "", ""};
|
||||
vector<string> elemens = {txt::g_confHilosInput , txt::g_confTiempoInput};
|
||||
ui::showTopTitle(&TITULO_PRINCIPAL);
|
||||
vector<string> entrada = ui::showCentralInputBox(&textos_init, &CONFIGURAR_TODO, &elemens, TITULO_PRINCIPAL.size());
|
||||
Config config2 = Config(atoi(entrada[0].c_str()), entrada[1]);
|
||||
@ -95,8 +97,8 @@ void userInterface(const int8_t *num_menu, vector<string> *mensaje, Config *conf
|
||||
}
|
||||
|
||||
case CONFIGURAR_HILOS: {
|
||||
vector<string> textos_init = {"Número de hilos actuales: " + to_string(config->getNumHilos()), "", ""};
|
||||
vector<string> elemens = {"- Número de hilos\t> "};
|
||||
vector<string> textos_init = {txt::g_confHilos + to_string(config->getNumHilos()), "", ""};
|
||||
vector<string> elemens = {txt::g_confHilosInput};
|
||||
vector<string> entrada = ui::showCentralInputBox(&textos_init, &CONFIGURAR_TODO, &elemens, TITULO_PRINCIPAL.size());
|
||||
config->setNumHilos(atoi(entrada[0].c_str()));
|
||||
cf::saveConfig(config);
|
||||
@ -105,8 +107,8 @@ void userInterface(const int8_t *num_menu, vector<string> *mensaje, Config *conf
|
||||
}
|
||||
|
||||
case CONFIGURAR_TIEMPO: {
|
||||
vector<string> textos_init = {"Tiempo actual" + config->getTiempo(), "", ""};
|
||||
vector<string> elemens = {"- Tiempo de ejecución\t> "};
|
||||
vector<string> textos_init = {txt::g_confTiempo + config->getTiempo(), "", ""};
|
||||
vector<string> elemens = {txt::g_confTiempoInput};
|
||||
vector<string> entrada = ui::showCentralInputBox(&textos_init, &CONFIGURAR_TODO, &elemens, TITULO_PRINCIPAL.size());
|
||||
config->setTiempo(entrada[0]);
|
||||
cf::saveConfig(config);
|
||||
@ -125,7 +127,7 @@ void userInterface(const int8_t *num_menu, vector<string> *mensaje, Config *conf
|
||||
|
||||
default: {
|
||||
ui::g_mensaje = true;
|
||||
*mensaje = {"¿Como has llegado aquí?", "Por si acaso vamos al menú principal"};
|
||||
*mensaje = {txt::g_errorGenerico_1, txt::g_errorGenerico_2};
|
||||
userInterface(&MENU_PRINCIPAL, mensaje, config);
|
||||
break;
|
||||
}
|
||||
@ -160,12 +162,12 @@ void showMenu(vector<string> *menu_elems, const int8_t *num_menu, Config *config
|
||||
switch (*num_menu) {
|
||||
|
||||
case MENU_PRINCIPAL: {
|
||||
mvwprintw(menuwin, 0, 1, "Menú Principal");
|
||||
mvwprintw(menuwin, 0, 1, txt::g_menuPrincipal.c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
case MENU_CONFIGURACION: {
|
||||
mvwprintw(menuwin, 0, 1, "Configuración");
|
||||
mvwprintw(menuwin, 0, 1, txt::g_menuConfigurar.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
105
src/textos.cpp
Normal file
105
src/textos.cpp
Normal file
@ -0,0 +1,105 @@
|
||||
#include "textos.hpp"
|
||||
#include "idiomas/es.hpp"
|
||||
#include "idiomas/gl.hpp"
|
||||
#include "idiomas/en.hpp"
|
||||
|
||||
std::string txt::g_noColor = "";
|
||||
std::string txt::g_errorGenerico_1 = "";
|
||||
std::string txt::g_errorGenerico_2 = "";
|
||||
std::string txt::g_menuPrincipal = "";
|
||||
std::string txt::g_menuPrincipal_1 = "";
|
||||
std::string txt::g_menuPrincipal_2 = "";
|
||||
std::string txt::g_menuPrincipal_3 = "";
|
||||
std::string txt::g_menuConfigurar = "";
|
||||
std::string txt::g_menuConfigurar_1 = "";
|
||||
std::string txt::g_menuConfigurar_2 = "";
|
||||
std::string txt::g_menuConfigurar_3 = "";
|
||||
std::string txt::g_menuConfigurar_4 = "";
|
||||
std::string txt::g_confTodo = "";
|
||||
std::string txt::g_confHilos = "";
|
||||
std::string txt::g_confTiempo = "";
|
||||
std::string txt::g_confHilosInput = "";
|
||||
std::string txt::g_confTiempoInput = "";
|
||||
|
||||
void txt::inicializarIdioma(std::string idioma){
|
||||
idioma = idioma.substr(0, idioma.find("."));
|
||||
|
||||
if(idioma == "gl_ES"){
|
||||
using namespace gl;
|
||||
txt::g_noColor = noColor;
|
||||
txt::g_errorGenerico_1 = errorGenerico_1;
|
||||
txt::g_errorGenerico_2 = errorGenerico_2;
|
||||
txt::g_menuPrincipal = menuPrincipal;
|
||||
txt::g_menuPrincipal_1 = menuPrincipal_1;
|
||||
txt::g_menuPrincipal_2 = menuPrincipal_2;
|
||||
txt::g_menuPrincipal_3 = menuPrincipal_3;
|
||||
txt::g_menuConfigurar = menuConfigurar;
|
||||
txt::g_menuConfigurar_1 = menuConfigurar_1;
|
||||
txt::g_menuConfigurar_2 = menuConfigurar_2;
|
||||
txt::g_menuConfigurar_3 = menuConfigurar_3;
|
||||
txt::g_menuConfigurar_4 = menuConfigurar_4;
|
||||
txt::g_confTodo = confTodo;
|
||||
txt::g_confHilos = confHilos;
|
||||
txt::g_confTiempo = confTiempo;
|
||||
txt::g_confHilosInput = confHilosInput;
|
||||
txt::g_confTiempoInput = confTiempoInput;
|
||||
}else if(idioma == "es_ES"){
|
||||
using namespace es;
|
||||
txt::g_noColor = noColor;
|
||||
txt::g_errorGenerico_1 = errorGenerico_1;
|
||||
txt::g_errorGenerico_2 = errorGenerico_2;
|
||||
txt::g_menuPrincipal = menuPrincipal;
|
||||
txt::g_menuPrincipal_1 = menuPrincipal_1;
|
||||
txt::g_menuPrincipal_2 = menuPrincipal_2;
|
||||
txt::g_menuPrincipal_3 = menuPrincipal_3;
|
||||
txt::g_menuConfigurar = menuConfigurar;
|
||||
txt::g_menuConfigurar_1 = menuConfigurar_1;
|
||||
txt::g_menuConfigurar_2 = menuConfigurar_2;
|
||||
txt::g_menuConfigurar_3 = menuConfigurar_3;
|
||||
txt::g_menuConfigurar_4 = menuConfigurar_4;
|
||||
txt::g_confTodo = confTodo;
|
||||
txt::g_confHilos = confHilos;
|
||||
txt::g_confTiempo = confTiempo;
|
||||
txt::g_confHilosInput = confHilosInput;
|
||||
txt::g_confTiempoInput = confTiempoInput;
|
||||
}else if(idioma == "en_US" || idioma == "en_EN"){
|
||||
using namespace en;
|
||||
txt::g_noColor = noColor;
|
||||
txt::g_errorGenerico_1 = errorGenerico_1;
|
||||
txt::g_errorGenerico_2 = errorGenerico_2;
|
||||
txt::g_menuPrincipal = menuPrincipal;
|
||||
txt::g_menuPrincipal_1 = menuPrincipal_1;
|
||||
txt::g_menuPrincipal_2 = menuPrincipal_2;
|
||||
txt::g_menuPrincipal_3 = menuPrincipal_3;
|
||||
txt::g_menuConfigurar = menuConfigurar;
|
||||
txt::g_menuConfigurar_1 = menuConfigurar_1;
|
||||
txt::g_menuConfigurar_2 = menuConfigurar_2;
|
||||
txt::g_menuConfigurar_3 = menuConfigurar_3;
|
||||
txt::g_menuConfigurar_4 = menuConfigurar_4;
|
||||
txt::g_confTodo = confTodo;
|
||||
txt::g_confHilos = confHilos;
|
||||
txt::g_confTiempo = confTiempo;
|
||||
txt::g_confHilosInput = confHilosInput;
|
||||
txt::g_confTiempoInput = confTiempoInput;
|
||||
}else{
|
||||
using namespace en;
|
||||
txt::g_noColor = noColor;
|
||||
txt::g_errorGenerico_1 = errorGenerico_1;
|
||||
txt::g_errorGenerico_2 = errorGenerico_2;
|
||||
txt::g_menuPrincipal = menuPrincipal;
|
||||
txt::g_menuPrincipal_1 = menuPrincipal_1;
|
||||
txt::g_menuPrincipal_2 = menuPrincipal_2;
|
||||
txt::g_menuPrincipal_3 = menuPrincipal_3;
|
||||
txt::g_menuConfigurar = menuConfigurar;
|
||||
txt::g_menuConfigurar_1 = menuConfigurar_1;
|
||||
txt::g_menuConfigurar_2 = menuConfigurar_2;
|
||||
txt::g_menuConfigurar_3 = menuConfigurar_3;
|
||||
txt::g_menuConfigurar_4 = menuConfigurar_4;
|
||||
txt::g_confTodo = confTodo;
|
||||
txt::g_confHilos = confHilos;
|
||||
txt::g_confTiempo = confTiempo;
|
||||
txt::g_confHilosInput = confHilosInput;
|
||||
txt::g_confTiempoInput = confTiempoInput;
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
#include "ui.hpp"
|
||||
#include "configFile.hpp"
|
||||
#include "textos.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -16,7 +17,7 @@ int8_t ui::initUI(const int8_t *menu_principal, const int8_t *menu_error) {
|
||||
noecho();
|
||||
cbreak();
|
||||
if (!has_colors()) {
|
||||
printw("El terminal no soporta colores");
|
||||
printw(txt::g_noColor.c_str());
|
||||
getch();
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user