I am not familiar with portigeese, but I assume it has a more complex grammar than english (as virtually every language has a more complex grammar than english). In general, you must use C's formating funktions like printf().
*Do you have a grammatical sex (like german) in portugeese ? Then you should at a variable <sex> into the XML files, to give items a sex. Persons already have an ingame sex, but you probably have to change profession names according to sex. English is probably the only language where gender-mainstreaming works. I recomend, to encode the sex into the profession strings, and use a function for every time it is printed, to declinate it. for example use curved brackets to indicate female only letters like "Police{wo}man". If the person is female, the parser simply has to dump the bracets and if he is male, dump the letters inside the bracets, too. The easiest way to do this, is to replace removed letters with a characte that cannot be printed, like SYN or DEL. A simpler, but more memory intensive methode is, to simply use two strings for every profession, one male and one female.
* LCS has a lot of code duplication. Reducing it helps you, as you need to patch less text. Some common strings should be written in global variables and inserted with %s when needed.
* You probaly need an array, of strings (*char[][]) representing the english word the for different case, sex and numerus. C only allows three dimensions, and one is consumed for the strings, so the array must be two dimensional. Im not familiar with portugeese, but in german for example you treat the plural as the fourth sex and use the same dimension for sex and number, so the dimension is (male,femal,neutral,plural). As protugeese has the same descent as french (two sexes, sexed plural), I assume this dimension were (male sing., female sing, male plural,female plural). Other words like his/her might need an array, too, if it is determined by the objects sex and number.
* C has some beautyfull funktions, to handle grammar, but for some reason, LCS never uses them. If you want to allow C escape codes in an LCS funktion, write a wraper, that accepts varargs and uses vspritf() to write the parsed string into a buffer, that apply the LCS funktion to the buffer. This should look like that :
#include <STDARG.H>
char addstrf_buffer[512];
/* Wrapper for addstr to allow formated strings */
void addstrf(const char format,va_list arglist)
{
vsprintf(addstrf_buffer,format,arglist);
addstr(addstrf_buffer);
}
/* example of a formated string */
void example(int female,const char *verb,const char *object,const char *reason)
{
addstrf("The police%sman %s %s %s at you%s.",
female?"wo":"",
verb,
female?"her":"his",
object,
reason
);
}
void main()
{
/* The policewoman swings her whip at you, for fetish. */
example(TRUE,"swings","whip",", for fetish");
/* The policeman fires his .44 magnum at you, because you're black. */
example(FALSE,"fires",".44 magnum",", because you're black.");
}
Using varargs is a case of advanced C Programming, but it will really help you. It can be used to simplify programming and significently reduce the code size.
Interesting Sources :
* look in your compiler manual for stdarg.h and its funktions
* get a book about advanced C-Programming
* Look at Nethack. The Files PLINE.C and VARARGS.H are very interesting, they contain useage of varargs for every possible platform ever used.
http://nethackwiki.com/wiki/Pline.c