TEST website instance!

A-code internationalisation

As of version 12.83, A-code is sufficiently UTF8 compliant to handle games with messages, vocabulary and entity names in languages other than English, including ones which use non-ASCII characters, provided (a) words are separated by ASCII blanks (octal 32) and (b) are parsed left to right. All you need is a UTF8-compliant text editor. While this degree of UTF8-compliance is only possible since A-code version 12.83, it is available in games using A-code styles from 10 upwards.

UTF8 compliance means that you can have texts and player vocabulary, including object/place names in any character set that can be represented in UTF8 encoding of Unicode. To activate this feature of the current A-code engine, add the UTF8 major directive to the game source header.

Of course, full game internationalisation has other challenges, which are nothing to do with character encoding.

  • Parsing of complex commands
    Some words, such a AND, THEN, AGAIN... have special meaning for the kernel. Different words will apply in different languages.
  • Modifying kernel messages
    While A-code leaves most of communication with the player to the game's code, there are a few occasions when the kernel responds directy -- e.g. about being unable to save a game. These kernel messages also need changing for languages other than English.
  • Echoing player's words grammatically
    When the game incorporates player command words into its responses, in English just echoing player's words is sufficient. Other languages typically need to be able to modify echoed words accoding to their grammar rules.

Parsing complex commands

A-code kernel has to be able to identify words being used to structure complex command: AND being used instead of a comma, and THEN being used instead of a semicolon. Furthermore, if the verb AGAIN is defined by the game, it is intercepted by the kernel and taken to men a request to repeat the previous command (see the section on automatic entities and flags in the A-code language documentation). There are a few other special words that have to be known to the kernel. The current complete list is as follows:

The obvious solution in writing a game in a language other than English is to declare the appropriate synonyms for such special words. (AND and THEN are defined automatically, but can be also defined explicitly as vocabulary words.) E.g. in Czech the equivalent of AND is A, and of THEN is PAK (or POTOM). Thus

WORD AND, A
WORD THEN, PAK, POTOM

enables these words to be used in place of AND and THEN.

There is, of course, an obvious snag to this simple solution. It leaves the English version of such special words in the player vocabulary, which may be very confusing to players (e.g. because of the typo correction mechanism). Or worse, those words might mean something else in some other language. To avoid such problems, one can "bar" English versions by prefixing them with the vertical bar ASCII character (|).

WORD |AND, A
WORD |THEN, PAK, POTOM

This makes the synonyms of a barred special word to be have the same effect, without adding the barred word itself to the list of defined terms. This makes it possible for that word to be defined in its own right and having another meaning altogether. As an example, the following is perfectly lega:

WORD |THEN, PAK, POTOM
WORD THEN

In this case words PAK and POTOM do have the special meaning of separating simple command within a complex command, but THEN itself has no special meaning at all. Any code references to THEN would then be referring to that last definition. This avoids any potential case of a clash between a reserved English vocabulary word and some word in another language.

If no synonyms are given, the excluded word can still be used by game code, if required.


Modifying kernel messages

There are some messages that the kernel does produce directly, instead of signalling its response to the game and letting the game to produce an appropriate message to the player. An obvious example is a query about savign a game under the same name as an already existing save: "There's already a game dumped under that name." follwed by "Do you really mean to overwrite it? ". Clearly some way is required for modifying such messages if A-code is to be used to write a non-English game.

From version 12.50 onwars, the kernel does provide an appropriate mechanism. Before displaying such a hardwired massage, the kernel first checks whether the game code has supplied an equivalent. If the equivalent exists, that is what is displayed. Otherwise the hard-wired default English message is shown

For example, if the game source defines a text named .K.REALLY.OVERWRITE, that text will be displayed instead of the default "Do you really mean to overwrite it? ". Each hard-wired message can be overriden by an appropriate .K.<some_name> text. You can find the full current definitions of such names and their default English texts in the appendix to this section.

You can also find that list as i18n_en.acd file in the extras sub-directory of the sources drectory of acdc. This file gives proper A-code definitions of .K. texts and can be (but dos not need to be) used as an include file in a game source. Some of these texts are only relevant for particular builds of the game, e.g. QT, or Windows console ones. Others will depend on use of a particular A-code feature, such as using the QUERY minor directive or replacing it with the CONTEXT mechanism).

The file is provided merely as a handy template for internationalising (or just customising!) kernel messages. To modify just some of those messages you only need to provide the definition of those specific message in a game's A-code source. It is only when writing a game in a language other than English that you should translate the whole of that template file.

As an illustration, alongside the i18n_en.acd the A-code tarball also contains a Russian version, kindly provided by Алексей Галкин as a part of his translation into Russian of my A-code implementation of Roger Frith's demo adventure The Cloak of Darkness.


Echoing player words grammatically

Echoing player words in Engish is easy enough. For example, if the player says TAKE CLOAK, responding with "You take the cloak" is fine, but in other langauges, player's CLOAK may have to be transformed from the nominative case to the genitive one. End even in English one may wish to reply with a plural (e.g. "There are no cloaks to be seen here") or transform an irregular verb into the past tense.

The current version of A-code does not as yet offer a way to do this, but I have a cunning plan :-) for a simple extension of the language which would deal with the easier aspect of this problem. Watch this space!

In the meantime you'll have to stucture game's responses to avoid the need for grammatical transformations.


Appendix: .K.* kernel text messages

text .K.DATA.DUMPED
  Game data dumped into the log file.
text .K.EXIT.ENTER
  (To exit, press ENTER)
text .K.IN.PROGRESS
  Restoring game in progress...
text .K.LOST.SESSION
  Oops! We seem to have lost your current game session! Sorry about that!
text .K.AS.YOU.WISH
  As you wish...
fragment .K.REALLY.OVERWRITE
  Do you really mean to overwrite it?_
text .K.ALREADY.HAVE.NAME
  There's already a game dumped under that name.
text .K.CHANGED.MIND
  Changed your mind, eh? Fine by me...
fragment .K.NAME.TO.RESTORE
  Name of saved game to restore:_
text .K.GAME.LIST
  You have the following saved games:
text .K.NO.SAVED.GAMES
  You have no saved games to restore.
fragment .K.NAME.TO.SAVE
  Name to save game under:_
fragment .K.YES.NO
  Eh? Do me a favour and answer yes or no! Which will it be?_
text .K.ASSUME.YES
  (OK, smartass... I'll assume you mean YES - so there!)
text .K.OK
  OK.
fragment .K.MORE
  [More?]
fragment .K.VERSION
  version
fragment .K.SUBMIT
  Submit
text .K.BROWSER.WELCOME
  Welcome to the A-code browser interface
text .K.BROWSER.INTRO
  This interface can be used entirely from the keyboard, as long as the
  command input field remains in focus. Commands can be submitted by pressing
  the RETURN key and arrow keys can be used to recall and edit previous
  commands.

  The appearance of the game can be customized by modifying the
  A-code configuration file acode.conf – this can be found in the
  A-code directory, called either .acode or acode, within your
  home directory. There you can also find individual game directories called by
  the game name, which is where saved games and log files are stored by
  default.

  The configuration file has ample comments to guide you, should
  you decide to make any changes. If by any chance this interface does not work
  for you, you can change the browser specification in that file to NONE and
  then run the game in the console mode from a terminal window.
fragment .K.BROWSER.PLAY
  Play
text .K.BROWSER.CODA
  (In case you are wondering why it is not possible to skip this intro page
  – it's because it is in fact a cunning workaround for a browser
  mis-feature, no names named. By clicking on the 'Play' button you will ensure
  that the browser behaves itself and gives keyboard focus to where the
  interface requests it to be.)
text .K.HTTP.INTRO
  The game can be played entirely from the keyboard, as long as the command
  input field remains in focus. Commands can be submitted by pressing the
  ENTER key (a.k.a. RETURN). Arrow keys allow recalling/editing previous
  commands. If you wish to stop playing and to continue at some other time,
  it is not necessary to use the save command – just open this page again
  and you will be offered the option of continuing the current game, if there
  is one. The game runs locally on your machine – there is no network access.
  All data storage relies on your browser's sand-boxed data store.
fragment .K.HTTP.CODA
  This JavaScript version of the game is made possible by the magic of
fragment .K.YOU.CAN
  You can
fragment .K.OR.LOAD
  or load a saved game
fragment .K.CONTINUE.GAME
  Continue your game
fragment .K.START.NEW.GAME
  Start a new game
fragment .K.OR
  or
text .K.CLOSE.BUTTON
  Close this tab/window
text .K.BROWSER.PARANOID
  (This will only work is your browser
is not being paranoid about security.) text .K.WRONG.VERSION Wrong game version! fragment .K.PLAY.AGAIN Play again

Back to the documentation index
To the Mipmip home page
Feel free to leave a comment!
Mike Arnautov (14 May 2025)