[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12. Internationalization

Berkeley Logo has limited support for non-English-speaking users. Alas, there is no Unicode support, and high-bit-on ASCII codes work in some contexts but not others.

If you want to translate Berkeley Logo for use with another language, there are three main things you have to do:

 
1. Primitive names
2. Error (and other) messages
3. Documentation

For primitive names, the easiest thing is to provide a startup file that defines aliases for the English primitive names, using COPYDEF:

 
COPYDEF "AVANT "FORWARD

This should take care of it, unless your language's name for one primitive is spelled like the English name of a different primitive. In that case you have to turn REDEFP on and be sure to copy the non-conflicting name before overwriting the conflicting one!

"Primitives" that are actually in the Logo library, of course, can just be replaced or augmented with native-language-named Logo procedures and filenames.

Of course Logo programs will still not look like your native language if the word order is dramatically different, especially if you don't put verbs before their objects.

For error messages, there is a file named ‘Messages’ in the ‘logolib’ directory with texts of messages, one per line. You can replace this with a file for your own language. Do not add, delete, or reorder lines; Logo finds messages by line number. The sequences %p, %s, and %t in these messages represent variable parts of the message and should not be translated. (%p PRINTs the variable part, while %s SHOWs it – that is, the difference is about whether or not brackets are shown surrounding a list. %t means that the variable part is a C text string rather than a Logo object.) If you want to change the order of two variable parts (no reorderable message has more than two), you would for example replace the line

 
%p doesn't like %s as input

with

 
%+s is a lousy input to %p

The plus sign tells the message printer to reverse the order; you must reverse the order of %p and %s, if both are used, to match. The plus sign goes just after the first percent sign in the message, which might not be at the beginning of the line. The sequence \n in a message represents a newline; don't be fooled into thinking that the n is part of the following word.

Some messages appear twice in the file; this isn't a mistake. The two spaces before to in I don't know how\ \ to aren't a mistake either. The message containing just %p is for user-provided error messages in THROW "ERROR. The message "\ \ in %s\n%s" is the part of all error messages that indicates where the error occurred if it was inside a procedure; you might want to change the word in to your language. %s defined\n is what LOAD prints for each procedure defined if the variable LOADNOISILY is TRUE. "to %p\nend\n\n" is what EDIT puts in the temporary file if you ask to edit a procedure that isn't already defined.

Also in the ‘Messages’ file are lines containing only one word each; the first of these is the word true. Some of these words are recognized by Logo in user input; some are generated by Logo; some are both. For example, the words TRUE and FALSE are recognized as Boolean values by IF and IFELSE, and are also generated by Logo as outputs from the primitive predicates such as EQUALP. The word END is recognized as the end of a procedure definition, and may be generated when Logo reconstructs a procedure body for PO or EDIT. I've used capital letters in this paragraph for easier reading, but the words in the ‘Messages’ file should be in lower case.

If you replace these with non-English words, Logo will recognize both the English names and your alternate names. For example, if you replace the word true with vrai then Logo will understand both of these:

 
IF "TRUE [PRINT "YES]
IF "VRAI [PRINT "YES]

The variable UseAlternateNames determines whether Logo will generate other-language names – for example, whether predicate functions return the other-language alternates for TRUE and FALSE. This variable is FALSE by default, meaning that the English words will be generated.

You might wish to have English-named predicate functions generate English TRUE and FALSE, while other-language-named predicates generate the alternate words. This can be done by leaving UseAlternateNames false, and instead of defining the other-language predicates with COPYDEF, do it this way:

 
to french.boolean :bool
if equalp :bool "true [output "vrai]
if equalp :bool "false [output "faux]
output :bool	; shouldn't happen
end

to make.french.predicate :french :english :arity
define :french `[[[inputs] ,[:arity]]
                 [output french.boolean
			    apply ,[word "" :english] :inputs]]
end

? make.french.predicate "egal? "equal? 2
? pr egal? 3 4
faux
? pr egal? 4 4
vrai
? pr equal? 3 4
false
? pr equal? 4 4
true

The third input to make.french.predicate is the number of inputs that the predicate expects. This solution isn't quite perfect because the infix predicates (=, <, >) will still output in English. If you want them to generate alternate-language words, set UseAlternateNames to TRUE instead.

Some of the words in this section of the ‘Messages’ file are names of Logo primitives (OUTPUT, STOP, GOTO, TAG, IF, IFELSE, TO, .MACRO). To translate these names, you must use COPYDEF as described earlier, in addition to changing the names in ‘Messages’. You should be consistent in these two steps. Don't forget the period in .macro!

For documentation, there are two kinds: this manual and the help files. The latter are generated automatically from this manual if you have a Unix system, so in that case you need only translate this manual, maintaining the format. (The automatic helpfile generator notices things like capital letters, tabs, hyphens, and equal signs at the beginnings of lines.) The program makefile.c may require modification because a few of the primitive names are special cases (e.g., LOG10 is the only name with digits included).

If you don't have Unix tools, you can just translate each helpfile individually. A period in a primitive name is represented as a D in the filename; there are no files for question marks because the HELP command looks for the file named after the corresponding primitive that ends in P.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Brian Harvey on September, 3 2008 using texi2html 1.78.