From 0511fb5e4d8b1c695190402008ae33959fa08730 Mon Sep 17 00:00:00 2001 From: Laurent Mazet Date: Thu, 13 Jun 2024 23:39:22 +0200 Subject: [PATCH] start translation table code --- bag-de.h | 4 ++++ bag-es.h | 4 ++++ bag-nl.h | 4 ++++ constant.c | 22 ++++++++++++++++++++++ constant.h | 2 ++ type.h | 10 ++++++++++ 6 files changed, 46 insertions(+) diff --git a/bag-de.h b/bag-de.h index 9b05f9c..fa0dd3f 100644 --- a/bag-de.h +++ b/bag-de.h @@ -73,6 +73,10 @@ static lettervalue_t _lettervalues_de[NB_LETTERVALUES_DE] = { static char *_extra_help_de = "a, u, o for AE, UE, OE"; +#define NB_TRANSLATIONS_DE 3 + +static trans_t _trans_table_de[NB_TRANSLATIONS_DE] = { { 'a', "Ä" }, { 'u', "Ü" }, { 'o', "Ö" } }; + #endif /* __BAG_DE__ */ /* vim: set ts=4 sw=4 et: */ diff --git a/bag-es.h b/bag-es.h index 974f396..40ddbaa 100644 --- a/bag-es.h +++ b/bag-es.h @@ -71,6 +71,10 @@ static lettervalue_t _lettervalues_es[NB_LETTERVALUES_ES] = { static char *_extra_help_es = "c, l, n, r for CH, LL, NN, RR"; +#define NB_TRANSLATIONS_ES 4 + +static trans_t _trans_table_es[NB_TRANSLATIONS_ES] = { { 'c', "CH" }, { 'l', "LL" }, { 'n', "Ñ" }, { 'r', "RR" } }; + #endif /* __BAG_ES__ */ /* vim: set ts=4 sw=4 et: */ diff --git a/bag-nl.h b/bag-nl.h index cd6794f..46c4f74 100644 --- a/bag-nl.h +++ b/bag-nl.h @@ -69,6 +69,10 @@ static lettervalue_t _lettervalues_nl[NB_LETTERVALUES_NL] = { static char *_extra_help_nl = "i for IJ"; +#define NB_TRANSLATIONS_NL 1 + +static trans_t _trans_table_nl[NB_TRANSLATIONS_NL] = { { 'i', "IJ" } }; + #endif /* __BAG_NL__ */ /* vim: set ts=4 sw=4 et: */ diff --git a/constant.c b/constant.c index 0e0b000..5033a37 100644 --- a/constant.c +++ b/constant.c @@ -36,6 +36,8 @@ board_t *getboard (char *name) static bag_t _bag = {0}; +static translation_t _translation = {0}; + bag_t *getbag (char *lang) { bag_t *pt = NULL; @@ -94,4 +96,24 @@ char *getextrahelp (char *lang) return pt; } +translation_t *gettranslationtable (char *lang) +{ + translation_t *pt = NULL; + + if (strcmp (lang, "de") == 0) { + pt = &_translation; + pt->nb = NB_TRANSLATIONS_DE; + pt->tab = _trans_table_de; + } else if (strcmp (lang, "es") == 0) { + pt = &_translation; + pt->nb = NB_TRANSLATIONS_ES; + pt->tab = _trans_table_es; + } else if (strcmp (lang, "nl") == 0) { + pt = &_translation; + pt->nb = NB_TRANSLATIONS_NL; + pt->tab = _trans_table_nl; + } + return pt; +} + /* vim: set ts=4 sw=4 et: */ diff --git a/constant.h b/constant.h index 1d7f0f4..7d4f485 100644 --- a/constant.h +++ b/constant.h @@ -9,6 +9,8 @@ bag_t *getbag (char *lang); char *getextrahelp (char *lang); +translation_t *gettranslationtable (char *lang); + #endif /* __CONSTANT_H__ */ /* vim: set ts=4 sw=4 et: */ diff --git a/type.h b/type.h index 6afcaa7..7f08b76 100644 --- a/type.h +++ b/type.h @@ -51,6 +51,16 @@ typedef struct { spelling_e *status; } word_t; +typedef struct { + char tile; + char *val; +} trans_t; + +typedef struct { + int nb; + trans_t *tab; +} translation_t; + #endif /* __TYPE_H__ */ /* vim: set ts=4 sw=4 et: */ -- 2.30.2