diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-04-04 18:46:15 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-04-04 18:46:15 +0000 |
| commit | 6dbcded21e7e9614b967b922987be6bcf3f3fe58 (patch) | |
| tree | cfa806296d8880c4136681c5cb96d06a2e856eb0 /src/language.c | |
| parent | 617ba439aab5f1798eb02618dfcfbed80a5baf28 (diff) | |
- moznost nastavit si klavesy na ovladanie v ~/.tuxanci-ng/keycontrol.conf
- moznost prekladat texty do roznych jazykov, defult jazyk je EN, nastavenie je v ~/.tuxanci-ng/lang.conf
- moznost nastavit server pomocou konfiguraku ./server.conf
- uptime v sekudach a samorestartovaci casocvac tam este _NIE_ _JE_
git-svn-id: http://opensvn.csie.org/tuxanci_ng@39 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/language.c')
| -rw-r--r-- | src/language.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/language.c b/src/language.c new file mode 100644 index 0000000..51a7d5b --- /dev/null +++ b/src/language.c @@ -0,0 +1,83 @@ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <assert.h> + +#include "main.h" +#include "list.h" +#include "homeDirector.h" +#include "textFile.h" +#include "language.h" + +static textFile_t *languageFile; + +void initLanguage() +{ + textFile_t *languageTypeFile; + char path[STR_PATH_SIZE]; + char *lang; + + sprintf(path, "%s/lang.conf", getHomeDirector()); + languageTypeFile = loadTextFile(path); + + if( languageTypeFile == NULL ) + { + fprintf(stderr, "Don't load %s\n", path); + fprintf(stderr, "I create %s\n", path); + + languageTypeFile = newTextFile(path); + addList(languageTypeFile->text, strdup("en") ); + saveTextFile(languageTypeFile); + } + + if( languageTypeFile == NULL ) + { + fprintf(stderr, "Don't create %s\n", path); + return; + } + + if( languageTypeFile->text->count == 0 ) + { + fprintf(stderr, "File %s empty\n", path); + return; + } + + lang = ((char *)languageTypeFile->text->list[0]); + printf("select lang %s\n", lang); + + sprintf(path, PATH_DATA "lang.%s", lang); + languageFile = loadTextFile(path); + + if( languageFile == NULL ) + { + fprintf(stderr, "Don't load %s\n", path); + } +} + +char* getMyText(char *key) +{ + int i; + int len; + + len = strlen(key); + + for( i = 0 ; i < languageFile->text->count ; i++ ) + { + char *line; + line = (char *) (languageFile->text->list[i]); + + if( strncmp(key, line, len) == 0 ) + { + return line+strlen(key)+1; + } + } + + return NULL; +} + +void quitLanguage() +{ + destroyTextFile(languageFile); +} + |