i18n of themes

This commit is contained in:
p.kosyh 2009-11-20 07:54:50 +00:00
parent 383208328c
commit ddd18c32a9
4 changed files with 15 additions and 14 deletions

View file

@ -89,7 +89,7 @@ static char *game_name(const char *path, const char *d_name)
char *p = getfilepath(path, MAIN_FILE);
if (!p)
goto err;
l = lookup_tag(p, "$Name:", "--");
l = lookup_tag(p, "Name", "--");
free(p);
if (l)
return l;
@ -534,8 +534,6 @@ int game_init(const char *name)
{
getcwd(game_cwd, sizeof(game_cwd));
if (!opt_lang || !opt_lang[0])
opt_lang = game_locale();
if (menu_lang_select(opt_lang) && menu_lang_select(LANG_DEF)) {
fprintf(stderr, "Can not load default language.\n");
exit(1);

View file

@ -87,6 +87,11 @@ int main(int argc, char **argv)
exit(1);
}
cfg_load();
if (!opt_lang || !opt_lang[0])
opt_lang = game_locale();
if (games_sw)
games_lookup(games_sw);
@ -99,8 +104,6 @@ int main(int argc, char **argv)
themes_lookup(game_local_themes_path());
games_lookup(game_local_games_path());
cfg_load();
if (noauto_sw)
opt_autosave = 0;
if (window_sw)

View file

@ -49,7 +49,7 @@ static char *slot_name(const char *path)
struct stat st;
char *l;
FILE *fd;
l = lookup_tag(path, "$Name:", "--");
l = lookup_tag(path, "Name", "--");
if (l) {
char *s = fromgame(l);
free(l);
@ -616,7 +616,7 @@ static char *lang_code(const char *str)
static char *lang_name(const char *path, const char *file)
{
char *l;
l = lookup_tag(path, "$Name:", ";");
l = lookup_tag(path, "Name", ";");
if (l)
return l;
return lang_code(file);

View file

@ -263,12 +263,10 @@ char *lookup_lang_tag(const char *fname, const char *tag, const char *comm)
{
char lang_tag[1024];
char *l;
snprintf(lang_tag, sizeof(lang_tag), "$%s(%s):", tag, opt_lang);
snprintf(lang_tag, sizeof(lang_tag), "%s(%s)", tag, opt_lang);
l = lookup_tag(fname, lang_tag, comm);
if (!l) {
snprintf(lang_tag, sizeof(lang_tag), "$%s:", tag);
l = lookup_tag(fname, lang_tag, comm);
}
if (!l)
l = lookup_tag(fname, tag, comm);
return l;
}
@ -276,15 +274,17 @@ char *parse_tag(char *line, const char *tag, const char *comm, int *brk)
{
char *l = line;
char *ns = NULL;
char ftag[1024];
snprintf(ftag, sizeof(ftag), "$%s:", tag);
l += strspn(l, " \t");
if (strncmp(l, comm, strlen(comm))) { /* non coment block */
*brk = 1;
return NULL;
}
l += strlen(comm); l += strspn(l, " \t");
if (strncmp(l, tag, strlen(tag)))
if (strncmp(l, ftag, strlen(ftag)))
return NULL;
l += strlen(tag);
l += strlen(ftag);
l += strspn(l, " \t");
ns = l;
l = find_in_esc(l, "\\$");