From 560bb6cf8b4cecf17f868230e14337a9c99c8169 Mon Sep 17 00:00:00 2001 From: matiasbian Date: Tue, 29 May 2018 19:56:28 -0300 Subject: [PATCH 1/4] gettext funcion applied to strings --- msgfmt | 0 msginit | 0 src/gfx_curses.c | 8 +++++--- src/gfx_terminal.c | 8 +++++--- src/highscore.c | 16 +++++++++------- src/main.c | 6 ++++++ xgettext | 0 7 files changed, 25 insertions(+), 13 deletions(-) create mode 100644 msgfmt create mode 100644 msginit create mode 100644 xgettext diff --git a/msgfmt b/msgfmt new file mode 100644 index 0000000..e69de29 diff --git a/msginit b/msginit new file mode 100644 index 0000000..e69de29 diff --git a/src/gfx_curses.c b/src/gfx_curses.c index 4db2467..649f206 100644 --- a/src/gfx_curses.c +++ b/src/gfx_curses.c @@ -3,6 +3,8 @@ #include #include "gfx.h" #include "merge.h" +#include +#include #define NUMBER_OF_COLORS 7 @@ -61,11 +63,11 @@ struct gfx_state* gfx_init(struct gamestate *g) void gfx_draw(struct gfx_state *s, struct gamestate *g) { if (g->score_last) - mvwprintw(s->window, 0, 0, "Score: %d (+%d)\n", g->score, g->score_last); + mvwprintw(s->window, 0, 0, gettext("Score: %d (+%d)\n"), g->score, g->score_last); else - mvwprintw(s->window, 0, 0, "Score: %d\n", g->score); + mvwprintw(s->window, 0, 0, gettext("Score: %d\n"), g->score); - mvwprintw(s->window, 1, 0, " Hi: %d\n", g->score_high); + mvwprintw(s->window, 1, 0, gettext(" Hil: %d\n"), g->score_high); wattron(s->window, A_DIM); iterate(g->opts->grid_width * (g->print_width + 2) + 1, waddch(s->window, '-')); diff --git a/src/gfx_terminal.c b/src/gfx_terminal.c index ec2de50..e5d3371 100644 --- a/src/gfx_terminal.c +++ b/src/gfx_terminal.c @@ -4,6 +4,8 @@ #include #include "merge.h" #include "gfx.h" +#include +#include #define iterate(n, expression)\ do {\ @@ -37,11 +39,11 @@ void gfx_draw(struct gfx_state *s, struct gamestate *g) #endif if (g->score_last) - printf("Score: %ld (+%ld)\n", g->score, g->score_last); + printf(gettext("Score: %ld (+%ld)\n"), g->score, g->score_last); else - printf("Score: %ld\n", g->score); + printf(gettext("Score: %ld\n"), g->score); - printf(" Hi: %ld\n", g->score_high); + printf(gettext(" Hi: %ld\n"), g->score_high); iterate((g->print_width + 2) * g->opts->grid_width + 1, printf("-")); printf("\n"); diff --git a/src/highscore.c b/src/highscore.c index f6ba15c..fbf51e3 100644 --- a/src/highscore.c +++ b/src/highscore.c @@ -5,6 +5,8 @@ #include #include #include "engine.h" +#include +#include const char *hs_dir_name = "2048"; const char *hs_file_name = "highscore"; @@ -53,7 +55,7 @@ void highscore_reset(void) const size_t resp_length = 16; char resp[resp_length]; - printf("Are you sure you want to reset your scores? Y(es) or N(o)\n"); + printf(gettext("Are you sure you want to reset your scores? Y(es) or N(o)\n")); while (1) { /* fgets is used to avoid queuing that may occur with getchar */ @@ -66,12 +68,12 @@ void highscore_reset(void) if (sl < resp_length) resp[sl - 1] = '\0'; - if (!strncmp(resp, "yes", resp_length) || !strncmp(resp, "y", resp_length)) + if (!strncmp(resp, gettext("yes"), resp_length) || !strncmp(resp, gettext("y"), resp_length)) goto reset_scores; else if (!strncmp(resp, "no", resp_length) || !strncmp(resp, "n", resp_length)) return; - printf("Please enter Yes or No\n"); + printf(gettext("Please enter Yes or No\n")); } reset_scores:; @@ -90,12 +92,12 @@ long highscore_load(struct gamestate *g) fd = fopen(hsfile, "w+"); if (fd == NULL) { - fprintf(stderr, "load: Failed to open highscore file\n"); + fprintf(stderr, gettext("load: Failed to open highscore file\n")); return 0; } if (fscanf(fd, "%ld", &result) != 1) { - fprintf(stderr, "load: Failed to parse highscore file\n"); + fprintf(stderr, gettext("load: Failed to parse highscore file\n")); result = 0; } @@ -117,12 +119,12 @@ void highscore_save(struct gamestate *g) FILE *fd = fopen(hsfile, "w"); if (fd == NULL) { - fprintf(stderr, "save: Failed to open highscore file\n"); + fprintf(stderr, gettext("save: Failed to open highscore file\n")); return; } if (fprintf(fd, "%ld", g->score) < 0) { - fprintf(stderr, "save: Failed to write highscore file\n"); + fprintf(stderr, gettext("save: Failed to write highscore file\n")); } fclose(fd); } diff --git a/src/main.c b/src/main.c index c5c62cd..ce4ff02 100644 --- a/src/main.c +++ b/src/main.c @@ -3,6 +3,8 @@ #include "ai.h" #include "engine.h" #include "gfx.h" +#include +#include void draw_then_sleep(struct gfx_state *s, struct gamestate *g) { @@ -13,6 +15,10 @@ void draw_then_sleep(struct gfx_state *s, struct gamestate *g) int main(int argc, char **argv) { + setlocale (LC_ALL, ""); + bindtextdomain ("gfx_terminal", "/usr/share/locale/"); + textdomain ("gfx_terminal"); + struct gamestate *g = gamestate_init(argc, argv); if (!g) { fatal("failed to allocate gamestate"); diff --git a/xgettext b/xgettext new file mode 100644 index 0000000..e69de29 From 1a02433aa3d136d3aa74ebbf6b4c80f9ae337489 Mon Sep 17 00:00:00 2001 From: matiasbian Date: Sun, 10 Jun 2018 19:17:40 -0300 Subject: [PATCH 2/4] fully translated to spanish --- 18n/es_AR/LC_MESSAGES/gfx_curses.mo | Bin 0 -> 606 bytes 18n/es_AR/LC_MESSAGES/gfx_terminal.mo | Bin 0 -> 590 bytes 18n/es_AR/LC_MESSAGES/highscore.mo | Bin 0 -> 1226 bytes msgfmt | 0 msginit | 0 po/es_AR/gfx_curses.po | 33 +++++++++++++++ po/es_AR/gfx_terminal.po | 33 +++++++++++++++ po/es_AR/highscore.po | 56 ++++++++++++++++++++++++++ po/gfx_curses.pot | 33 +++++++++++++++ po/gfx_terminal.pot | 33 +++++++++++++++ po/highscore.pot | 56 ++++++++++++++++++++++++++ src/main.c | 7 ++-- xgettext | 0 13 files changed, 248 insertions(+), 3 deletions(-) create mode 100644 18n/es_AR/LC_MESSAGES/gfx_curses.mo create mode 100644 18n/es_AR/LC_MESSAGES/gfx_terminal.mo create mode 100644 18n/es_AR/LC_MESSAGES/highscore.mo delete mode 100644 msgfmt delete mode 100644 msginit create mode 100644 po/es_AR/gfx_curses.po create mode 100644 po/es_AR/gfx_terminal.po create mode 100644 po/es_AR/highscore.po create mode 100644 po/gfx_curses.pot create mode 100644 po/gfx_terminal.pot create mode 100644 po/highscore.pot delete mode 100644 xgettext diff --git a/18n/es_AR/LC_MESSAGES/gfx_curses.mo b/18n/es_AR/LC_MESSAGES/gfx_curses.mo new file mode 100644 index 0000000000000000000000000000000000000000..1e442ee70724a791ce2e866ecc42436dfb84dc0e GIT binary patch literal 606 zcmaKp&q^FY5XQ%7E`1UY;vquiASlx7%xYxpbtS}T6dYW1^yHjVOU=#ouu;*Qo0UCiT3R_s1yVMu%!gd4(g)8Lh@8%C1Afst=#ErS%7pb*-kdzK2Bd|>qdL2so&3<2KVyP zFVrO}-Gl5Dt&_fgkZ$t$&DYL#A}!z0naPzd1jNV6vq9NdEcvFfl@p-rr=#n4doWD< kvl>44A)4#a5*qCr%+&oK4axo8rK)hauD>qcExc^;5pF%Cng9R* literal 0 HcmV?d00001 diff --git a/18n/es_AR/LC_MESSAGES/gfx_terminal.mo b/18n/es_AR/LC_MESSAGES/gfx_terminal.mo new file mode 100644 index 0000000000000000000000000000000000000000..36069f384ba0c71eb6d73620d1568edd0f231e9c GIT binary patch literal 590 zcmZ{h%}yIJ5P;3!f#n3JB5@dmkU+?=32hY|f`AZ81Y4qH%ZbadF&m>@d$GL;koo|9 z0B*hX8TtskN1vsWfB=cs(x-3MGduqKGdKCbXiO3d#5OTSoD;)Q5HrN}v%iz)h#y2Y z#@J8tJTX1a*erR8{DJ(5OldYjP&n#OVhjL|lz`=|AFy6xtb7;4${J-?1J<$TN+zDS z`}|B=r;HZR*=ru}eQCj2tJ`azehs>^FxKO%hd7M2naf-F>hLlo_^v7=xLQ| zSgG;wBd>mj%9aSLJlqUJD&$>xqlV4@UAOsEcY@CI*rIkBdSeAd)Egaa=OfE|d0i@* zT`1JMX^tvePfWfOoS;riOeK#c<^p;JYUKtm(*mRmqIT4JJz!-$44OuJscF5tf;R5u zt=}jzRJsny0Iie0@hv{&wb#1gzAmNZEuEOY(y4&jh4MisD=lXH(AeAw(8cJ}HL7)Z n3L7gL78_7mtLRHMHM>@daP;y8!+Mehd5nW?^eA-T;397rNiU)8NsO zAgF=oz%$_2V59_}!RNtWhITQ(1Qgnr0W1esfaBvL7K$?kb<4D8a&q}_vLm%8Z^*J^ zU$`u}*uZ*BYbADNGL~8;Qx1c6#?mpd_H1d5-N0kQATu(FXiln(lS0Y#S<|LUHwQYj zf%TI?eQBX}Jj%&!{-@OOpdG9HNvXYHk6qBV<^{)IEF@x;ty4xv)UG$4*5{kF+U%?> zEVsfA_l@;p$)ze0Px91>u8AmYFLy=5vh+w2v(lrmiAr@+RPKxF1FB9&)d^9#Td5#W zba-18;-|+wJd9hE&Wo;<+GWxk8_^Q9rK9QIfcYhF<%+X)CG||&!*!0wruQgZlse62 z%A(7%7g61&cmbsmMbmz$R&32q)H^eoa^8(QJY&oo2C?Is{gFsS?4H*<;nKoV^XNvZ zgiW8RMKqW0qFRiVT%nWwc)#4Z0z>@kbHJl(bSfTW~d`O=Uz)YvGj{$#ttNF(x+N xRNICU{!5v92m8CKC*8@^LBFDyGbPXG(k3!N7yZxHr)0B>ty({8?JjUC_yePHXTJad literal 0 HcmV?d00001 diff --git a/msgfmt b/msgfmt deleted file mode 100644 index e69de29..0000000 diff --git a/msginit b/msginit deleted file mode 100644 index e69de29..0000000 diff --git a/po/es_AR/gfx_curses.po b/po/es_AR/gfx_curses.po new file mode 100644 index 0000000..0616ffd --- /dev/null +++ b/po/es_AR/gfx_curses.po @@ -0,0 +1,33 @@ +# Spanish translations for 2048 package. +# Copyright (C) 2018 THE 2048'S COPYRIGHT HOLDER +# This file is distributed under the same license as the 2048 package. +# Matias , 2018. +# +msgid "" +msgstr "" +"Project-Id-Version: 2048 v1.0.1\n" +"Report-Msgid-Bugs-To: matiasezequielbian@gmail.com\n" +"POT-Creation-Date: 2018-04-26 18:58-0300\n" +"PO-Revision-Date: 2018-04-26 19:00-0300\n" +"Last-Translator: Matias \n" +"Language-Team: Spanish\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/gfx_curses.c:70 +#, c-format +msgid " Hi: %d\n" +msgstr "Puntuación Máxima: %d\n" + +#: src/gfx_curses.c:68 +#, c-format +msgid "Score: %d\n" +msgstr "Puntuación: %d\n" + +#: src/gfx_curses.c:66 +#, c-format +msgid "Score: %d (+%d)\n" +msgstr "Puntuación: %d (+%d)\n" diff --git a/po/es_AR/gfx_terminal.po b/po/es_AR/gfx_terminal.po new file mode 100644 index 0000000..471f98e --- /dev/null +++ b/po/es_AR/gfx_terminal.po @@ -0,0 +1,33 @@ +# Spanish translations for PACKAGE package. +# Copyright (C) 2018 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Matias , 2018. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-26 19:02-0300\n" +"PO-Revision-Date: 2018-04-26 19:03-0300\n" +"Last-Translator: Matias \n" +"Language-Team: Spanish\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/gfx_terminal.c:46 +#, c-format +msgid " Hi: %ld\n" +msgstr "Puntuación Máxima: %ld\n" + +#: src/gfx_terminal.c:44 +#, c-format +msgid "Score: %ld\n" +msgstr "Puntuación: %ld\n" + +#: src/gfx_terminal.c:42 +#, c-format +msgid "Score: %ld (+%ld)\n" +msgstr "Puntuación: %ld (+%ld)\n" diff --git a/po/es_AR/highscore.po b/po/es_AR/highscore.po new file mode 100644 index 0000000..0af49c7 --- /dev/null +++ b/po/es_AR/highscore.po @@ -0,0 +1,56 @@ +# Spanish translations for PACKAGE package. +# Copyright (C) 2018 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# Matias , 2018. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-05-17 18:12-0300\n" +"PO-Revision-Date: 2018-05-17 18:19-0300\n" +"Last-Translator: Matias \n" +"Language-Team: Argentinian \n" +"Language: es_AR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: src/highscore.c:58 +#, c-format +msgid "Are you sure you want to reset your scores? Y(es) or N(o)\n" +msgstr "¿Estás seguro que quieres reiniciar tus puntuaciones? (S)i o (N)o\n" + +#: src/highscore.c:76 +#, c-format +msgid "Please enter Yes or No\n" +msgstr "Por favor ingresa Si o No\n" + +#: src/highscore.c:95 +#, c-format +msgid "load: Failed to open highscore file\n" +msgstr "Carga: Error al abrir el archivo de puntuaciones máximas\n" + +#: src/highscore.c:100 +#, c-format +msgid "load: Failed to parse highscore file\n" +msgstr "Carga: Error al parsear el archivo de puntuaciones máximas\n" + +#: src/highscore.c:122 +#, c-format +msgid "save: Failed to open highscore file\n" +msgstr "Guardado: Error al abrir el archivo de puntuaciones máximas\n" + +#: src/highscore.c:127 +#, c-format +msgid "save: Failed to write highscore file\n" +msgstr "Guardado: Error al escribir el archivo de puntuaciones máximas\n" + +#: src/highscore.c:71 +msgid "y" +msgstr "s" + +#: src/highscore.c:71 +msgid "yes" +msgstr "si" diff --git a/po/gfx_curses.pot b/po/gfx_curses.pot new file mode 100644 index 0000000..ccb9233 --- /dev/null +++ b/po/gfx_curses.pot @@ -0,0 +1,33 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: 2048 v1.0.1\n" +"Report-Msgid-Bugs-To: matiasezequielbian@gmail.com\n" +"POT-Creation-Date: 2018-04-26 18:58-0300\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/gfx_curses.c:70 +#, c-format +msgid " Hi: %d\n" +msgstr "" + +#: src/gfx_curses.c:68 +#, c-format +msgid "Score: %d\n" +msgstr "" + +#: src/gfx_curses.c:66 +#, c-format +msgid "Score: %d (+%d)\n" +msgstr "" diff --git a/po/gfx_terminal.pot b/po/gfx_terminal.pot new file mode 100644 index 0000000..fb745c6 --- /dev/null +++ b/po/gfx_terminal.pot @@ -0,0 +1,33 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-04-26 19:02-0300\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/gfx_terminal.c:46 +#, c-format +msgid " Hi: %ld\n" +msgstr "" + +#: src/gfx_terminal.c:44 +#, c-format +msgid "Score: %ld\n" +msgstr "" + +#: src/gfx_terminal.c:42 +#, c-format +msgid "Score: %ld (+%ld)\n" +msgstr "" diff --git a/po/highscore.pot b/po/highscore.pot new file mode 100644 index 0000000..151d4e2 --- /dev/null +++ b/po/highscore.pot @@ -0,0 +1,56 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2018-05-17 18:12-0300\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: src/highscore.c:58 +#, c-format +msgid "Are you sure you want to reset your scores? Y(es) or N(o)\n" +msgstr "" + +#: src/highscore.c:76 +#, c-format +msgid "Please enter Yes or No\n" +msgstr "" + +#: src/highscore.c:95 +#, c-format +msgid "load: Failed to open highscore file\n" +msgstr "" + +#: src/highscore.c:100 +#, c-format +msgid "load: Failed to parse highscore file\n" +msgstr "" + +#: src/highscore.c:122 +#, c-format +msgid "save: Failed to open highscore file\n" +msgstr "" + +#: src/highscore.c:127 +#, c-format +msgid "save: Failed to write highscore file\n" +msgstr "" + +#: src/highscore.c:71 +msgid "y" +msgstr "" + +#: src/highscore.c:71 +msgid "yes" +msgstr "" diff --git a/src/main.c b/src/main.c index ce4ff02..d888c5a 100644 --- a/src/main.c +++ b/src/main.c @@ -5,6 +5,7 @@ #include "gfx.h" #include #include +#include void draw_then_sleep(struct gfx_state *s, struct gamestate *g) { @@ -15,9 +16,9 @@ void draw_then_sleep(struct gfx_state *s, struct gamestate *g) int main(int argc, char **argv) { - setlocale (LC_ALL, ""); - bindtextdomain ("gfx_terminal", "/usr/share/locale/"); - textdomain ("gfx_terminal"); + setlocale (LC_ALL, ""); + bindtextdomain ("gfx_terminal", strcat(getenv("PWD"),"/18n/")); + textdomain ("gfx_terminal"); struct gamestate *g = gamestate_init(argc, argv); if (!g) { diff --git a/xgettext b/xgettext deleted file mode 100644 index e69de29..0000000 From 70897bc9db6735c65e1e3e205c289ec94e1ac156 Mon Sep 17 00:00:00 2001 From: matiasbian Date: Sun, 10 Jun 2018 19:33:13 -0300 Subject: [PATCH 3/4] Documentation added --- HowToTranslate.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 HowToTranslate.md diff --git a/HowToTranslate.md b/HowToTranslate.md new file mode 100644 index 0000000..092b827 --- /dev/null +++ b/HowToTranslate.md @@ -0,0 +1,53 @@ + +# How to translate 2048 to another language. + +First, if you do not have Gettext, get it by entering the following command by terminal + +``` +sudo apt-get install gettext +``` + +We aim to have the following structure for our directory: + +./po/language_name/file.po + +So, go to the ./po directory and then create a directory with your language standard name. + +for example: + +``` +mkdir po/es_AR +``` + +The next step is to generate the .po files with the following command (change 'es_AR' by your language standard name): +``` +msginit --input=po/gfx_curses.pot --locale=es_AR --output=po/es_AR/gfx_curses.po +msginit --input=po/gfx_terminal.pot --locale=es_AR --output=po/es_AR/gfx_terminal.po +msginit --input=po/highscore.pot --locale=es_AR --output=po/es_AR/gfx_highscore.po +``` + +### Translation + +Now, we can translate the strings: + +so, go to ./po/language_name/ and translate the strings in the .po files with a text editor. + +for example: +![Screenshot](https://k62.kn3.net/5/0/D/B/4/4/870.png) + + +Nwe should create the directory where we'll place the .mo files (change es_AR by your language standard name): + +``` +mkdir 18n/es_AR/LC_MESSAGES +``` + +The last step is to generate the .mo file: + +``` +msgfmt --output-file=/18n/es_AR/LC_MESSAGES/gfx_curses.mo po/es_AR/gfx_curses.po +msgfmt --output-file=/18n/es_AR/LC_MESSAGES/gfx_terminal.mo po/es_AR/gfx_terminal.po +msgfmt --output-file=/18n/es_AR/LC_MESSAGES/highscore.mo po/es_AR/highscore.po +``` + +##And this is it! From 6ad9b164547e471aa7fa31ba0357e62fd9ca4dc3 Mon Sep 17 00:00:00 2001 From: matiasbian Date: Thu, 21 Jun 2018 19:45:08 -0300 Subject: [PATCH 4/4] gettext.h added - gettenv overwrite fixed. --- src/gfx_curses.c | 2 +- src/main.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/gfx_curses.c b/src/gfx_curses.c index 649f206..5b7dd3c 100644 --- a/src/gfx_curses.c +++ b/src/gfx_curses.c @@ -3,7 +3,7 @@ #include #include "gfx.h" #include "merge.h" -#include +#include #include #define NUMBER_OF_COLORS 7 diff --git a/src/main.c b/src/main.c index d888c5a..51cf663 100644 --- a/src/main.c +++ b/src/main.c @@ -14,10 +14,23 @@ void draw_then_sleep(struct gfx_state *s, struct gamestate *g) gfx_sleep(160 / g->opts->grid_width); } +char *targetDir(char *env, char *path) +{ + char *dir; + char *dirEnv; + dirEnv = getenv(env); + dir = malloc(strlen(dirEnv) + strlen(path) + 1); + strcpy(dir, dirEnv); + strcat(dir,path); + return dir; +} + int main(int argc, char **argv) { + + setlocale (LC_ALL, ""); - bindtextdomain ("gfx_terminal", strcat(getenv("PWD"),"/18n/")); + bindtextdomain ("gfx_terminal", targetDir("PWD","/18n/")); textdomain ("gfx_terminal"); struct gamestate *g = gamestate_init(argc, argv);