Author: cazfi Date: Sun Aug 23 20:52:33 2015 New Revision: 29663 URL: http://svn.gna.org/viewcvs/freeciv?rev=29663&view=rev Log: Save scenario name and description with gettext marking.
See patch #6273 Modified: branches/S2_6/server/savegame2.c branches/S2_6/utility/registry_ini.c branches/S2_6/utility/registry_ini.h Modified: branches/S2_6/server/savegame2.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/savegame2.c?rev=29663&r1=29662&r2=29663&view=diff ============================================================================== --- branches/S2_6/server/savegame2.c (original) +++ branches/S2_6/server/savegame2.c Sun Aug 23 20:52:33 2015 @@ -2469,6 +2469,8 @@ ****************************************************************************/ static void sg_save_scenario(struct savedata *saving) { + struct entry *mod_entry; + /* Check status and return if not OK (sg_success != TRUE). */ sg_check_ret(); @@ -2478,9 +2480,11 @@ } secfile_insert_bool(saving->file, TRUE, "scenario.is_scenario"); - secfile_insert_str(saving->file, game.scenario.name, "scenario.name"); - secfile_insert_str(saving->file, game.scenario.description, - "scenario.description"); + mod_entry = secfile_insert_str(saving->file, game.scenario.name, "scenario.name"); + entry_str_set_gt_marking(mod_entry, TRUE); + mod_entry = secfile_insert_str(saving->file, game.scenario.description, + "scenario.description"); + entry_str_set_gt_marking(mod_entry, TRUE); secfile_insert_bool(saving->file, game.scenario.save_random, "scenario.save_random"); secfile_insert_bool(saving->file, game.scenario.players, "scenario.players"); secfile_insert_bool(saving->file, game.scenario.startpos_nations, Modified: branches/S2_6/utility/registry_ini.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/utility/registry_ini.c?rev=29663&r1=29662&r2=29663&view=diff ============================================================================== --- branches/S2_6/utility/registry_ini.c (original) +++ branches/S2_6/utility/registry_ini.c Sun Aug 23 20:52:33 2015 @@ -656,6 +656,7 @@ for (ent_iter = entry_list_head(section_entries(psection)); ent_iter && (pentry = entry_list_link_data(ent_iter)); ent_iter = entry_list_link_next(ent_iter)) { + const char *comment; /* Tables: break out of this loop if this is a non-table * entry (pentry and ent_iter unchanged) or after table (pentry @@ -807,8 +808,9 @@ ent_iter = col_iter; } - if (entry_comment(pentry)) { - fz_fprintf(fs, "#%s\n", entry_comment(pentry)); + comment = entry_comment(pentry); + if (comment) { + fz_fprintf(fs, "#%s\n", comment); } else { fz_fprintf(fs, "\n"); } @@ -2836,6 +2838,7 @@ struct { char *value; /* Malloced string. */ bool escaped; /* " or $. Usually TRUE */ + bool gt_marking; /* Save with gettext marking. */ } string; }; }; @@ -2930,6 +2933,7 @@ pentry->type = ENTRY_STR; pentry->string.value = fc_strdup(NULL != value ? value : ""); pentry->string.escaped = escaped; + pentry->string.gt_marking = FALSE; } return pentry; @@ -3220,6 +3224,20 @@ ENTRY_STR == pentry->type, FALSE); pentry->string.escaped = escaped; + return TRUE; +} + +/************************************************************************** + Sets if the string should get gettext marking. Returns TRUE on success. +**************************************************************************/ +bool entry_str_set_gt_marking(struct entry *pentry, bool gt_marking) +{ + SECFILE_RETURN_VAL_IF_FAIL(NULL, NULL, NULL != pentry, FALSE); + SECFILE_RETURN_VAL_IF_FAIL(pentry->psection->secfile, pentry->psection, + ENTRY_STR == pentry->type, FALSE); + + pentry->string.gt_marking = gt_marking; + return TRUE; } @@ -3240,7 +3258,11 @@ case ENTRY_STR: if (pentry->string.escaped) { make_escapes(pentry->string.value, buf, sizeof(buf)); - fz_fprintf(fs, "\"%s\"", buf); + if (pentry->string.gt_marking) { + fz_fprintf(fs, "_(\"%s\")", buf); + } else { + fz_fprintf(fs, "\"%s\"", buf); + } } else { fz_fprintf(fs, "$%s$", pentry->string.value); } Modified: branches/S2_6/utility/registry_ini.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/utility/registry_ini.h?rev=29663&r1=29662&r2=29663&view=diff ============================================================================== --- branches/S2_6/utility/registry_ini.h (original) +++ branches/S2_6/utility/registry_ini.h Sun Aug 23 20:52:33 2015 @@ -612,6 +612,7 @@ bool entry_str_set(struct entry *pentry, const char *value); bool entry_str_escaped(const struct entry *pentry); bool entry_str_set_escaped(struct entry *pentry, bool escaped); +bool entry_str_set_gt_marking(struct entry *pentry, bool gt_marking); #ifdef __cplusplus } _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits