Translate Angband 3.1.0 to other language

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • tangar
    replied
    Russian version of Angband

    It's a bit old thread, but I just wanna share that I've found Russian version of Angband 3.0.5:



    It's pretty good translated, even got 'cases' (ends of words) which is pretty impotant for Russian language

    It will be fun to add it to Angband repo: http://rephial.org/release/3.0.5 so this version won't vanish

    Leave a comment:


  • Nick
    replied
    Originally posted by Pete Mack
    The cleanest way to introduce Latin-1 support is to strip out the graphics implementation the z-term and main-xxx.c is using, and just support it natively. (After removing graphics, there is almost no additional cost.)
    Then bring back graphics as a clean implementation using a better model.
    Awesome! A volunteer!

    Leave a comment:


  • Pete Mack
    replied
    The cleanest way to introduce Latin-1 support is to strip out the graphics implementation the z-term and main-xxx.c is using, and just support it natively. (After removing graphics, there is almost no additional cost.)
    Then bring back graphics as a clean implementation using a better model.

    Leave a comment:


  • hernaldo
    replied
    nppangband, what IDE do you use for compile or develop? I don't get a Debug step by step with Eclipse. I also tried with VC++ 8.0 and I could not.

    How long more do you think will implement the xchar or UTF-8 in the official release of Angband?
    Ask so wait.

    Leave a comment:


  • Nick
    replied
    Thanks Jeff, that's brilliant - I'm going to start a new thread on this.

    Leave a comment:


  • nppangband
    replied
    Originally posted by takkaria
    maybe we should be bringing lua back...
    Please, no. Lua was a bigger PITA than anything unicode could possibly bring.

    I am happy to help with implementing x-char.

    Nick - I just posted another version of NPP, aptly titled:



    But the x-char features are no longer buggy, and it works with what is essentially the Angband v3.1.2v2 beta source. I have already done all the conversion and de-bugging, and I am happy to help out adding this to vanilla. No need for somebody else to re-invent the wheel.

    But I beg the Angband dev team........no Lua. Anything but Lua.

    Leave a comment:


  • Nick
    replied
    Originally posted by takkaria
    Moving to unicode requires a change of fonts aside from all the code changes, so it will be a real PITA and it's possible the benefits will not outweigh the costs. So, I guess including xchars in V in the meantime is a better idea than blocking it.
    Right! That's a yes! I don't need to listen to anything else lalallalalla

    maybe we should be bringing lua back...

    Leave a comment:


  • takkaria
    replied
    Originally posted by Nick
    I'm inclined to favour the "include xchars as a quick fix, but aim to move to UTF-8 asap" approach, but I agree we need takkaria's approval on the first bit of that. From my personal point of view, I would like to add xchars to the AngbandBase code (as I'm planning to incorporate that into FA, and I don't want to remove xchars from FA); however I want AngbandBase to remain aligned with V. So I'm going to do unconnected stuff (or possibly nothing ) on AngbandBase until the situation clarifies.

    As to unicode handling - I'm guessing pretty much everything can deal with it, but only guessing.
    Moving to unicode requires a change of fonts aside from all the code changes, so it will be a real PITA and it's possible the benefits will not outweigh the costs. So, I guess including xchars in V in the meantime is a better idea than blocking it.

    PS. translation is something i've always wanted to support in the game, but I think to do it properly you do really need to have a scripting language to hold the language packs, given the complexity of angband's text handling. maybe we should be bringing lua back...

    Leave a comment:


  • nppangband
    replied
    I tried your test baove, but I couldn't get it to work either. It only seems to work if it is read from the edit files (look in artifact.txt, or monster.txt for examples), which, up until now, is all we have needed it to work.

    A simple one to test is in p-class.txt. Change the entry for Dunadan and change it to:

    D['u]nadan

    and then start up a new character and see if it displays correctly. That should work as a starting point.

    Leave a comment:


  • hernaldo
    replied
    I using Windows XP Prof, i compile using Mingw from the command line
    > mingw32-make.exe -f makefile.win

    I checked all and see that it works (finally, yes!) for the dinamic as "Choose New or Open from file Menu" o "STR, Dex points" or "Your 'race' determines various intrinsic factors and bonuses."

    But for the static text as "Bug reports to ..." or "For resourses and link..." or "Please select your character from the menu below", don't' work yet.
    It is assumed that when any text is show in the screen, it reaching "vstrnfmt" and there It get to "s" case:

    Code:
    	
    /* String */
    case 's':
    {
    	cptr arg;
    	char arg2[1024];
    
    	/* Get the next argument */
    	arg = va_arg(vp, cptr);
    
    	/* Hack -- convert NULL to EMPTY */
    	if (!arg) arg = "";
    
    	/* Prevent buffer overflows */
    	(void)my_strcpy(arg2, arg, sizeof(arg2));
    
    	/* Translate it to 8-bit (Latin-1) */
    	[B]xstr_trans[/B](arg2, LATIN1);
            ...
    But when I put a message box, only the dinamic text pass for here, but the static text does'nt!!
    -I shall not want to copy another function?


    Besides, is that I can't use the Latin character ż=191 because it shows "?" in the game. In the "static const xchar_type latin1_encode[]" table does not appear because the table start in the latin character 192, but it appear in "byte char_tables[256][CHAR_TABLE_SLOTS]" table.
    -that could be happening? I need add this character to the table? or add it in the fonts?

    thanks for your support!

    Leave a comment:


  • nppangband
    replied
    Originally posted by hernaldo
    ok, i understand.
    I tried for four hours today to link function with accents xstr_trans. I placed several calls in different parts of the "xstr_trans" function, but nothing worked. I put a MessageBox and I see that I don't get the "encode_to_xchar" function.

    {snip}

    What else I can check?

    thanks a lot!!
    THere is no need to edit text_out_e. It already calls vstrnfmt, which handles the conversation. You can paste the vstrnfmt directly from NPP into Angband and that works.

    Which operating system are you using to test this?

    Leave a comment:


  • hernaldo
    replied
    ok, i understand.
    I tried for four hours today to link function with accents xstr_trans. I placed several calls in different parts of the "xstr_trans" function, but nothing worked. I put a MessageBox and I see that I don't get the "encode_to_xchar" function.

    I had forgotten to modify the default font in main-win.c, I changed to:
    Code:
    #define DEFAULT_FONT	"8x16x.FON"
    Then, I put the [~n]:
    Code:
    #define BIRTH_MENU_HELPTEXT \ 
    {lightblue} test [~n]...
    Then, the code says (here i don't change nothing):
    Code:
    static void print_menu_instructions(void)
    {
    	/* Clear screen */
    	Term_clear();
    	
    	/* Output to the screen */
    	text_out_hook = text_out_to_screen;
    	
    	/* Indent output */
    	text_out_indent = QUESTION_COL;
    	Term_gotoxy(QUESTION_COL, HEADER_ROW);
    	
    	/* Display some helpful information */
    	[B]text_out_e[/B](BIRTH_MENU_HELPTEXT);
    	
    	/* Reset text_out() indentation */
    	text_out_indent = 0;
    }
    Then, following the code, we have:
    Code:
    void text_out_e(const char *fmt, ...)
    {
    	
    	char buf[1024];
    	char smallbuf[1024];
    	va_list vp;
    
    	const char *start, *next, *text, *tag;
    	size_t textlen, taglen = 0;
    
    	/* Begin the Varargs Stuff */
    	va_start(vp, fmt);
    
    	/* Do the va_arg fmt to the buffer */
    	(void)[B]vstrnfmt[/B](buf, sizeof(buf), fmt, vp);  -> [B]here I call to xstr_trans function???[/B]
    
    	/* End the Varargs Stuff */
    	va_end(vp);
    
    	start = buf;
    	while (next_section(start, 0, &text, &textlen, &tag, &taglen, &next))
    	{
    		int a = -1;
    
    		memcpy(smallbuf, text, textlen);
    		smallbuf[textlen] = 0;
    
    		if (tag)
    		{
    			char tagbuffer[11];
    
    			/* Colour names are less than 11 characters long. */
    			assert(taglen < 11);
    
    			memcpy(tagbuffer, tag, taglen);
    			tagbuffer[taglen] = '\0';
    
    			a = color_text_to_attr(tagbuffer);
    		}
    		
    		if (a == -1) 
    			a = TERM_WHITE;
    
    		
    		/* Output now */
    		text_out_hook(a, smallbuf);   [B]-> OR HERE I call to xstr_trans function???[/B]
    
    
    		start = next;
    	}
    }
    This is the code of text_out_hook (i don't think that i might modify):
    Code:
    Extern.h:
    extern void (*text_out_hook)(byte a, cptr str);
    
    Variable.c
    void (*text_out_hook)(byte a, cptr str);
    Finally, it's the code of vstrnfmt functoid in z-form.c, where i see that is ok:
    Code:
    size_t vstrnfmt(char *buf, size_t max, cptr fmt, va_list vp)
    {
    	cptr s;
    
    	/* The argument is "long" */
    	bool do_long;
    
    	/* The argument needs "processing" */
    	bool do_xtra;
    
    	/* Bytes used in buffer */
    	size_t n;
    
    	/* Bytes used in format sequence */
    	size_t q;
    
    	/* Format sequence */
    	char aux[128];
    
    	/* Resulting string */
    	char tmp[1024];
    
    
    	/* Fatal error - no buffer length */
    	if (!max) quit("Called vstrnfmt() with empty buffer!");
    
    
    	/* Mega-Hack -- treat "no format" as "empty string" */
    	if (!fmt) fmt = "";
    
    
    	/* Begin the buffer */
    	n = 0;
    
    	/* Begin the format string */
    	s = fmt;
    
    	/* Scan the format string */
    	while (TRUE)
    	{
    		type_union tval = END;
    
    		/* All done */
    		if (!*s) break;
    
    		/* Normal character */
    		if (*s != '%')
    		{
    			/* Check total length */
    			if (n == max-1) break;
    
    			/* Save the character */
    			buf[n++] = *s++;
    
    			/* Continue */
    			continue;
    		}
    
    		/* Skip the "percent" */
    		s++;
    
    		/* Pre-process "%%" */
    		if (*s == '%')
    		{
    			/* Check total length */
    			if (n == max-1) break;
    
    			/* Save the percent */
    			buf[n++] = '%';
    
    			/* Skip the "%" */
    			s++;
    
    			/* Continue */
    			continue;
    		}
    
    		/* Pre-process "%n" */
    		if (*s == 'n')
    		{
    			size_t *arg;
    
    			/* Get the next argument */
    			arg = va_arg(vp, size_t *);
    
    			/* Save the current length */
    			(*arg) = n;
    
    			/* Skip the "n" */
    			s++;
    
    			/* Continue */
    			continue;
    		}
    
    
    		/* Begin the "aux" string */
    		q = 0;
    
    		/* Save the "percent" */
    		aux[q++] = '%';
    
    		/* Assume no "long" argument */
    		do_long = FALSE;
    
    		/* Assume no "xtra" processing */
    		do_xtra = FALSE;
    
    		/* Build the "aux" string */
    		while (TRUE)
    		{
    			/* Error -- format sequence is not terminated */
    			if (!*s)
    			{
    				/* Terminate the buffer */
    				buf[0] = '\0';
    
    				/* Return "error" */
    				return (0);
    			}
    
    			/* Error -- format sequence may be too long */
    			if (q > 100)
    			{
    				/* Terminate the buffer */
    				buf[0] = '\0';
    
    				/* Return "error" */
    				return (0);
    			}
    
    			/* Handle "alphabetic" chars */
    			if (isalpha((unsigned char)*s))
    			{
    				/* Hack -- handle "long" request */
    				if (*s == 'l')
    				{
    					/* Save the character */
    					aux[q++] = *s++;
    
    					/* Note the "long" flag */
    					do_long = TRUE;
    				}
    
    				/* Mega-Hack -- handle "extra-long" request */
    				else if (*s == 'L')
    				{
    					/* Error -- illegal format char */
    					buf[0] = '\0';
    
    					/* Return "error" */
    					return (0);
    				}
    
    				/* Handle normal end of format sequence */
    				else
    				{
    					/* Save the character */
    					aux[q++] = *s++;
    
    					/* Stop processing the format sequence */
    					break;
    				}
    			}
    
    			/* Handle "non-alphabetic" chars */
    			else
    			{
    				/* Hack -- Handle 'star' (for "variable length" argument) */
    				if (*s == '*')
    				{
    					int arg;
    
    					/* Get the next argument */
    					arg = va_arg(vp, int);
    
    					/* Hack -- append the "length" */
    					sprintf(aux + q, "%d", arg);
    
    					/* Hack -- accept the "length" */
    					while (aux[q]) q++;
    
    					/* Skip the "*" */
    					s++;
    				}
    
    				/* Mega-Hack -- Handle 'caret' (for "uppercase" request) */
    				else if (*s == '^')
    				{
    					/* Note the "xtra" flag */
    					do_xtra = TRUE;
    
    					/* Skip the "^" */
    					s++;
    				}
    
    				/* Collect "normal" characters (digits, "-", "+", ".", etc) */
    				else
    				{
    					/* Save the character */
    					aux[q++] = *s++;
    				}
    			}
    		}
    
    
    		/* Terminate "aux" */
    		aux[q] = '\0';
    
    		/* Clear "tmp" */
    		tmp[0] = '\0';
    
    		/* Parse a type_union */
    		if (aux[q-1] == 'y')
    		{
    			tval = va_arg(vp, type_union);
    
    			if (do_long)
    			{
    				/* Error -- illegal type_union argument */
    				buf[0] = '\0';
    
    				/* Return "error" */
    				return (0);
    			}
    
    			/* Replace aux terminator with proper printf char */
    			if (tval.t == T_CHAR) aux[q-1] = 'c';
    			else if (tval.t == T_INT) aux[q-1] = 'd';
    			else if (tval.t == T_FLOAT) aux[q-1] = 'f';
    			else if (tval.t == T_STRING) aux[q-1] = 's';
    			else
    			{ 
    				buf[0] = '\0';
    				return (0);
    			}
    		}
    
    		/* Process the "format" symbol */
    		switch (aux[q-1])
    		{
    			/* Simple Character -- standard format */
    			case 'c':
    			{
    				int arg;
    
    				/* Get the next argument */
    				arg = tval.t == T_END ? va_arg(vp, int) : tval.u.c;
    
    				/* Format the argument */
    				sprintf(tmp, aux, arg);
    
    				/* Done */
    				break;
    			}
    
    			/* Signed Integers -- standard format */
    			case 'd': case 'i':
    			{
    				if (do_long)
    				{
    					long arg;
    
    					/* Get the next argument */
    					arg = va_arg(vp, long);
    
    					/* Format the argument */
    					sprintf(tmp, aux, arg);
    				}
    				else
    				{
    					int arg;
    
    					/* Get the next argument */
    					arg = tval.t == T_END ? va_arg(vp, int) : tval.u.i;
    
    					/* Format the argument */
    					sprintf(tmp, aux, arg);
    				}
    
    				/* Done */
    				break;
    			}
    
    			/* Unsigned Integers -- various formats */
    			case 'u': case 'o': case 'x': case 'X':
    			{
    				if (do_long)
    				{
    					unsigned long arg;
    
    					/* Get the next argument */
    					arg = va_arg(vp, unsigned long);
    
    					/* Format the argument */
    					sprintf(tmp, aux, arg);
    				}
    				else
    				{
    					unsigned int arg;
    
    					/* Get the next argument */
    					arg = va_arg(vp, unsigned int);
    
    					/* Format the argument */
    					sprintf(tmp, aux, arg);
    				}
    
    				/* Done */
    				break;
    			}
    
    			/* Floating Point -- various formats */
    			case 'f':
    			case 'e': case 'E':
    			case 'g': case 'G':
    			{
    				double arg;
    
    				/* Get the next argument */
    				arg = tval.t == T_END ? va_arg(vp, double) : tval.u.f;
    
    				/* Format the argument */
    				sprintf(tmp, aux, arg);
    
    				/* Done */
    				break;
    			}
    
    			/* Pointer -- implementation varies */
    			case 'p':
    			{
    				void *arg;
    
    				/* Get the next argument */
    				arg = va_arg(vp, void*);
    
    				/* Format the argument */
    				sprintf(tmp, aux, arg);
    
    				/* Done */
    				break;
    			}
    
    			/* String */
    			case 's':
    			{
    				cptr arg;
    				char arg2[1024];
    
    				/* Get the next argument */
    				arg = tval.t == T_END ? va_arg(vp, cptr) : tval.u.s;
    
    				/* Hack -- convert NULL to EMPTY */
    				if (!arg) arg = "";
    
    				/* Prevent buffer overflows */
    				(void)my_strcpy(arg2, arg, sizeof(arg2));
    
    				/* Translate it to 8-bit (Latin-1) */
     				xstr_trans(arg2, LATIN1);
    
    				/* Format the argument */
    				sprintf(tmp, aux, arg2);
    
    				/* Done */
    				break;
    			}
    
    #if 0 /* Later */
    			/* Binary */
    			case 'b':
    			{
    				int arg;
    				size_t i, max = 32;
    				u32b bitmask;
    				char out[32 + 1];
    
    				/* Get the next argument */
    				arg = va_arg(vp, int);
    
    				/* Check our aux string */
    				switch (aux[0])
    				{
    					case '1': max = 2;  break;
    					case '2': max = 4;  break;
    					case '3': max = 8;  break;
    					case '4': max = 16; break;
    					default: 
    					case '5': max = 32; break;
    				}
    				/* Format specially */
    				for (i = 1; i <= max; i++, bitmask *= 2)
    				{
    					if (arg & bitmask) out[max - i] = '1';
    					else out[max - i] = '0';
    				}
    
    				/* Terminate */
    				out[max] = '\0';
    
    				/* Append the argument */
    				my_strcpy(tmp, out, sizeof tmp);
    
    				/* Done */
    				break;
    			}
    #endif
    
    			/* Oops */
    			default:
    			{
    				/* Error -- illegal format char */
    				buf[0] = '\0';
    
    				/* Return "error" */
    				return (0);
    			}
    		}
    
    
    		/* Mega-Hack -- handle "capitalization" */
    		if (do_xtra)
    		{
    			for (q = 0; tmp[q]; q++)
    			{
    				/* Notice first non-space */
    				if (!my_isspace((unsigned char)tmp[q]))
    				{
    					/* Capitalize if possible */
    					if (my_islower((unsigned char)tmp[q]))
    						tmp[q] = my_toupper((unsigned char)tmp[q]);
    
    					/* Done */
    					break;
    				}
    			}
    		}
    
    		/* Now append "tmp" to "buf" */
    		for (q = 0; tmp[q]; q++)
    		{
    			/* Check total length */
    			if (n == max-1) break;
    
    			/* Save the character */
    			buf[n++] = tmp[q];
    		}
    	}
    
    
    	/* Terminate buffer */
    	buf[n] = '\0';
    
    	/* Return length */
    	return (n);
    }
    What else I can check?

    thanks a lot!!
    Last edited by hernaldo; July 24, 2010, 08:47.

    Leave a comment:


  • nppangband
    replied
    You can't enter the characters directly. The game has to be converted from ASCII to unicode for that to be possible. This patch is just a hack to have them display onscreen.

    Take a look at the conversion chart in latin1_encode in z-form.c. You have to type "[~n]" in a string and run it through xstr_trans to get the game to type "ń"

    Leave a comment:


  • hernaldo
    replied
    OK, it compile!

    But, I don't get see the acents (é), maybe I do something wrong.

    First: I changed ui-birth.c, the line 135 says:
    Code:
    #define BIRTH_MENU_HELPTEXT \
    	"{lightblue}Please select your character...
    I put the test code:
    Code:
    #define BIRTH_MENU_HELPTEXT \
    	"{lightblue}test á é
    Second: I copy the fonts from FA to my Anband / Lib / xtra / font
    I think that the text use the "5x8.font", Now it will use "5x8x.font"
    Also, I changed the "Makefile" file , because it says:

    Code:
    OBJECTIVE_DATA = \
    	copying.txt:${DATA_PATH}/xtra/font  \
    	5x8.fon:${DATA_PATH}/xtra/font      \
    I changed for:
    Code:
    OBJECTIVE_DATA = \
    	copying.txt:${DATA_PATH}/xtra/font  \
    	[B]5x8x.fon[/B]:${DATA_PATH}/xtra/font      \
    Third: I changed the "config.h" file, because that says:

    Code:
    #define DEFAULT_X11_FONT_0	"10x20"
    #define DEFAULT_X11_FONT_1		"9x15"
    #define DEFAULT_X11_FONT_2		"9x15"
    #define DEFAULT_X11_FONT_3		"5x8"
    #define DEFAULT_X11_FONT_4		"5x8"
    #define DEFAULT_X11_FONT_5		"5x8"
    #define DEFAULT_X11_FONT_6		"5x8"
    #define DEFAULT_X11_FONT_7		"5x8"
    I changed for:
    Code:
    #define DEFAULT_X11_FONT_0	"10x20"
    #define DEFAULT_X11_FONT_1		"9x15"
    #define DEFAULT_X11_FONT_2		"9x15"
    #define DEFAULT_X11_FONT_3		"5x8x"
    #define DEFAULT_X11_FONT_4		"5x8x"
    #define DEFAULT_X11_FONT_5		"5x8x"
    #define DEFAULT_X11_FONT_6		"5x8x"
    #define DEFAULT_X11_FONT_7		"5x8x"

    I need to do something to make it work?

    thanks and bye!

    Leave a comment:


  • nppangband
    replied
    Originally posted by hernaldo
    Ok thanks!
    I'm going to try modify the code. But I've a questions becouse this lines i don't find in the FA or NPPAngband code:



    what mean "typedef struct xchar_type xchar_type;" and "T->xchar_hook"
    are an error?
    You need the structure xchar_type. You can find it (along with many of the functions listed above) in z-form.h, around line 95.

    T->xchar_hook needs to be added to the structure term (line 237 of z-term.h). If you grep xchar_hook you will see you need to add some code in main-win.c (and the other operating systems that can handle the extended characters). It is in the function term_data_link:

    after these lines:

    t->wipe_hook = Term_wipe_win;
    t->text_hook = Term_text_win;
    t->pict_hook = Term_pict_win;

    add this:

    t->xchar_hook = Term_xchar_win;

    Also, I think I fixed the final problem yesterday...so you won't find this is the source code you downloaded. In z-term.c, you will find a function called term_addstr. Replace that function with the one below. Only the first 6 or 7 lines are different:

    errr Term_addstr(int n, byte a, cptr buf)
    {
    int k;

    int w = Term->wid;

    errr res = 0;

    char s[1024];

    /* Copy to a rewriteable string */
    my_strcpy(s, buf, 1024);

    /* Translate it to 7-bit ASCII or system-specific format */
    xstr_trans(s, LATIN1);

    /* Handle "unusable" cursor */
    if (Term->scr->cu) return (-1);

    /* Obtain maximal length */
    k = (n < 0) ? (w + 1) : n;

    /* Obtain the usable string length */
    for (n = 0; (n < k) && s[n]; n++) /* loop */;

    /* React to reaching the edge of the screen */
    if (Term->scr->cx + n >= w) res = n = w - Term->scr->cx;

    /* Queue the first "n" characters for display */
    Term_queue_chars(Term->scr->cx, Term->scr->cy, n, a, s);

    /* Advance the cursor */
    Term->scr->cx += n;

    /* Hack -- Notice "Useless" cursor */
    if (res) Term->scr->cu = 1;

    /* Success (usually) */
    return (res);
    }

    Leave a comment:

Working...
😀
😂
🥰
😘
🤢
😎
😞
😡
👍
👎