Merge branch 'spanishTra' of https://github.com/matiasbian/2048-cli into matiasbian-spanishTra

master
Marc Tiehuis 6 years ago
commit 0e81799f02
  1. BIN
      18n/es_AR/LC_MESSAGES/gfx_curses.mo
  2. BIN
      18n/es_AR/LC_MESSAGES/gfx_terminal.mo
  3. BIN
      18n/es_AR/LC_MESSAGES/highscore.mo
  4. 53
      HowToTranslate.md
  5. 33
      po/es_AR/gfx_curses.po
  6. 33
      po/es_AR/gfx_terminal.po
  7. 56
      po/es_AR/highscore.po
  8. 33
      po/gfx_curses.pot
  9. 33
      po/gfx_terminal.pot
  10. 56
      po/highscore.pot
  11. 14
      src/gfx_curses.c
  12. 12
      src/gfx_terminal.c
  13. 16
      src/highscore.c
  14. 20
      src/main.c

@ -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!

@ -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 <matiasezequielbian@gmail.com>, 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 <matiasezequielbian@gmail.com>\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"

@ -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 <matiasezequielbian@gmail.com>, 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 <matiasezequielbian@gmail.com>\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"

@ -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 <matiasezequielbian@gmail.com>, 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 <matiasezequielbian@gmail.com>\n"
"Language-Team: Argentinian <translation-es-AR@lists.sourceforge.net>\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"

@ -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 <EMAIL@ADDRESS>, 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 <matiasezequielbian@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 ""

@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 ""

@ -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 <EMAIL@ADDRESS>, 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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 ""

@ -3,6 +3,8 @@
#include <unistd.h>
#include "gfx.h"
#include "merge.h"
#include <gettext.h>
#include <locale.h>
#define NUMBER_OF_COLORS 7
@ -62,14 +64,14 @@ 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);
if (g->score >= g->score_high)
g->score_high = g->score;
mvwprintw(s->window, 1, 0, " Hi: %d\n", g->score_high);
if (g->score >= g->score_high)
g->score_high = g->score;
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, '-'));

@ -4,6 +4,8 @@
#include <unistd.h>
#include "merge.h"
#include "gfx.h"
#include <libintl.h>
#include <locale.h>
#define iterate(n, expression)\
do {\
@ -37,14 +39,14 @@ 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);
if (g->score >= g->score_high)
g->score_high = g->score;
if (g->score >= g->score_high)
g->score_high = 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");

@ -5,6 +5,8 @@
#include <sys/stat.h>
#include <sys/types.h>
#include "engine.h"
#include <libintl.h>
#include <locale.h>
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);
}

@ -3,6 +3,9 @@
#include "ai.h"
#include "engine.h"
#include "gfx.h"
#include <libintl.h>
#include <locale.h>
#include <string.h>
void draw_then_sleep(struct gfx_state *s, struct gamestate *g)
{
@ -11,8 +14,25 @@ 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", targetDir("PWD","/18n/"));
textdomain ("gfx_terminal");
struct gamestate *g = gamestate_init(argc, argv);
if (!g) {
fatal("failed to allocate gamestate");

Loading…
Cancel
Save