Skip to content

i18n Problems

tajmone edited this page Jan 15, 2019 · 2 revisions

This page illustrates some problems encountered while implementing the Italian translation of Alan Standard Library, their workarounds and the known limitations for which I couldn't find any workaround.

Some of these problems might affect internationalization of Alan to other languages too, and not just Italian; so I hope this document might be of guidance to anyone embarking on the task of translating the Alan library to another locale.

Other languages to which these problems might apply:

  • French

If you are aware of other languages affected by these problems, please edit this page and add them to the list.


Table of Contents


Give and Take Example

I've included in the Wiki an Alan source file to illustrate on a small scale potential conflicts with Italian language:

The source file is well commented and (hopefully) self explaining. It brings to attention two main problems, which are likely to show up in other circumstances as well:

  1. Prepositions that can take a contracted form with apostrophe,
  2. Prepositions which could also be imperative commands.

The full source of the file is reproduced at the end of this page.

Contracted Prepositions

IMPORTANT!!! — The problem mentioned here, relating to handling apostrophes in tokens, has now been solved by a new feature (see commit 1bfc8f7) that will be available in Alan 3.0beta7. The feature is also available in the developer snaphshot of Alan 3.0beta6 build 1852.

In Italian, some nouns require a preposition in contracted form with apostrophe, which doesn't allow space separation with the noun that follows it. This introduces a problem in Alan because the parser will see the preposition and noun as a single token.

For the benefit of non Italian speakers, I've added some reference tables and links at the end of this article.

When it comes to articles, the solution is rather simple, you only have to create an alias for the object so that the form with the article is interpreted as the noun:

THE albero IsA ACTOR AT lounge.
--| "albero" (tree) masculine singular
  NAME albero.
  NAME 'l''albero'. --> make l'albero = albero
END THE albero.

... so when the player types x l'albero (x the tree), the Alan parser sees x albero (x tree).

But when it comes to prepositions, things are a bit more complicate because we'd need to split the token in two separate words — eg, dall'albero (from the tree) should be seen as da albero (from tree). Unfortunately, Alan doesn't seem to support multi-token aliasing; so these won't work:

SYNONYMS 'dall''albero' = 'da', 'albero'. --> Error: 103 E !!!
SYNONYMS 'dall''albero' = da albero.      --> Error: 102 E !!!

There doesn't seem to be any good solution to this problem, except forcing the player to separate the preposition in his commands by inserting a space after the apostrphe (prendi mela dall' albero) or by omitting the apostrophe altogether (prendi mela dall albero).

This compromise isn't ideal, because it demands the player to misuse the Italian language in favour of a broken syntax to accomodate the limitations of the parser. On the other hand, similar problems with apostrophes have a long history in Italian IF (either due to authoring systems intrinsic limitations, or to poor implementation of synonyms in single adventures), and are certainly not news for the average player.

Having said that, the author must remember to also implement the preposition with and without apostrophe as synonms:

    'dall''', dall = da. -- dall' / dall (masc.sing.)*
--| * " dall " is not correct Italian, but a workaround to the limitation mentioned above.

It's worth mentioning at this point that the "a" preposition (to) in the "all'" form can't be made a synomym withouth apostrophe, due to conflicts with the Predefined English Player Word "ALL":

SYNONYMS
    alla, allo   = a.   -- alla (fem.sing.) | allo (masc.sing.)
    alle, ai     = a.   -- alle (fem.plur.) | ai   (masc.plur)
    'all'''      = a.   -- all' / all (masc.sing.)

--  all          = a.   --| CAN'T BE USED AS ALTERNATIVE because of conflict with
--|                         English ALL word:
--| 333 E : The word 'all' is defined to be both a synonym and another word class.

Conflict Between Preposition and Verb

In Italian, "dai" can mean both "from the" (masc.plur.) and "give" (imperative 2nd person sing). This poses a problem due to conflicts with the prepositions used in verbs like take from.

Usually, all variants of a preposition are implemented as SYNONYMS of its basic form so that they can be covered by the same SYNTAX definition:

SYNONYMS
    dalla, dallo   = da. -- dalla (fem.sing.) | dallo (masc.sing.)
    dalle          = da. -- dalle (fem.plur.)

... etc. (there are more). But when it comes to "dai", we can't implement it as synonym because it would conflcit with verb "dai" (give):

SYNTAX give = 'dai' (obj) 'a' (recipient)
  WHERE obj ISA OBJECT
    ELSE SAY "$1 non è un oggetto!".
  AND recipient ISA ACTOR
    ELSE SAY "$2 non è un attore!".

The workaround here is to create an alternative SYNTAX for the take from verb, specifically covering the dai preposition (instead of relying on synonyms converting it to the base preposition):

SYNTAX take_from = 'prendi' (obj) 'da' (recipient)
  WHERE obj ISA OBJECT
    ELSE SAY "$1 non è un oggetto!".
  AND recipient ISA ACTOR
    ELSE SAY "$2 non è un attore!".

SYNTAX take_from = 'prendi' (obj) 'dai' (recipient). --> YES, this doesn't conflict with verb 'dai'!

This workaround adds a bit more work on the author's side, but it's a clean solution that works seamlessly on the player's side.

Italian Language Quick References

Prepositions Contractions

For more info, see:

The prepositions enclosed in brackets in the follwing table are not relevant to translating Alan to Italian (they are rarely used forms in modern Italian):

il lo la l' i gli (gl') le
a al allo alla all' ai agli (agl') alle
da dal dallo dalla dall' dai dagli (dagl') dalle
di del dello della dell' dei degli (degl') delle
in nel nello nella nell' nei negli (negl') nelle
su sul sullo sulla sull' sui sugli (sugl') sulle
con col (collo) (colla) (coll') coi (cogli) (cogl') (colle)
per (pel) / (pil) (pello) / (pillo) (pella) / (pilla) (pell') / (pill') (pei) / (pie) (pegli) / (pigli) (pegl') / (pigl') (pelle)

Full Example Sourcecode

Here is the full source of the give_and_take.alan example of the problems mentioned in this page.

--==============================================================================
--| "GIVE AND TAKE" v1 (2018/05/17)                              | Alan 3.0beta5
--|  by Tristano Ajmone                                          | Public Domain
--==============================================================================
--| This is a small demo to illustrate potential conflicts, workarounds and known
--| Alan limitations in dealing with:
--|
--| (1) Italian verbs TAKE FROM (prendi da) and GIVE (dai) when player types
--|     "prendi dai" (masc.plur.) and "dai" (imperative).
--| (2) Prepositions which have apostrophe contraction forms (all', dall', etc.)
--|     and how aliasing can't solve the problem.
--|
--| This is a small scale, minimal viable reproduction of the problem, and many
--| other cases of potential conflicts are not dealt with herein. Possibly:
--|   "dallo" = "give it"      (masc.sing.) OR "from the" (masc.sing.)
--|   "dalla" = "give it"      (femm.sing.) OR "from the" (femm.sing.)
--|   "dalle" = "give them"    (femm.plur.) OR "from the" (femm.plur.)
--|   "dagli" = "give to him"  (masc.plur.) OR "from the" (masc.plur.)
--|   "dalle" = "give to ther" (femm.plur.) OR "from the" (femm.plur.)
--+-----------------------------------------------------------------------------
THE lounge IsA LOCATION
END THE lounge.

THE Bob IsA ACTOR AT lounge.
END THE Bob.

THE maestri IsA ACTOR AT lounge.
-- "maestri" (male teachers) masculine plural
END THE maestri.

THE mela IsA OBJECT AT lounge.
-- "mela" (apple) femminine singular
END THE mela.

THE albero IsA ACTOR AT lounge.
--| "albero" (tree) masculine singular
  NAME albero.
  NAME 'l''albero'. --> make l'albero = albero
END THE albero.
--| FAILED attempts to make the parser understand: dall'albero = da albero
--| None of the following works:
-- SYNONYMS 'dall''' = da.                   --> doesn't catch "dall'albero"
-- SYNONYMS 'dall''albero' = 'da', 'albero'. --> Err: 103 E
-- SYNONYMS 'dall''albero' = da albero.      --> Err: 102 E
--|
--| It seems like Alan simply can't be made to handle all the various prepositions
--| with apostrophe, which means that these will never work:
--|
--|   dall'<noun m.s.> = from the <noun>
--|   dell'<noun m.s.> =   of the <noun>
--|   nell'<noun m.s.> =   in the <noun>
--|   sull'<noun m.s.> =   on the <noun>
--|    all'<noun m.s.> =   to the <noun>
--|
--| ... unless we impose on the final player not to use the apostrophe -- which
--| is quite a demanding expectation, for we'd be asking him/her to forget good
--| linguistic habits in favour of broken Italian. Or we could ask the player to
--| add a space between the preposition and the noun (eg: dall' albero), which
--| sounds more reasonable (but just about so). Anyhow, this is a limit which
--| affects the player experience, and most liekly one that will affect not only
--| Italian but other languages which use apostrophes in prepositions (French).

--==============================================================================
-- GIVE TO
--==============================================================================
--| "dai mela a Bob"      (give apple to Bob)
--| "dai mela ai maestri" (give apple to teachers)

SYNTAX give = 'dai' (obj) 'a' (recipient)
  WHERE obj ISA OBJECT
    ELSE SAY "$1 non è un oggetto!".
  AND recipient ISA ACTOR
    ELSE SAY "$2 non è un attore!".

SYNTAX give = 'dai' (obj) 'all' (recipient). --> YES, this doesn't conflict with 'ALL'!

SYNONYMS
    alla, allo   = a.   -- alla (fem.sing.) | allo (masc.sing.)
    alle, ai     = a.   -- alle (fem.plur.) | ai   (masc.plur)
    'all'''      = a.   -- all' / all (masc.sing.)

--  all          = a.   --| CAN'T BE USED AS ALTERNATIVE because of conflict with
--|                         English ALL word:
--| 333 E : The word 'all' is defined to be both a synonym and another word class.
--|
--| Beside, " all " isn't correct Italian, but could have been a workaround to the
--| limitation mentioned above.

--==============================================================================
-- TAKE FROM
--==============================================================================
--| "prendi mela da Bob"       (take apple from Bob)
--| "prendi mela dai maestri"  (take apple from teachers)
--| "prendi mela dall'albero"* (take apple from tree)
--|
--| * doesn't work! only "dall' albero" or "dall albero" work.

SYNTAX take_from = 'prendi' (obj) 'da' (recipient)
  WHERE obj ISA OBJECT
    ELSE SAY "$1 non è un oggetto!".
  AND recipient ISA ACTOR
    ELSE SAY "$2 non è un attore!".

SYNTAX take_from = 'prendi' (obj) 'dai' (recipient). --> YES, this doesn't conflict with verb 'dai'!


ADD TO EVERY OBJECT

  VERB give
    DOES ONLY
      "Dai $+1 a $+2."
  END VERB.

  VERB take_from
    DOES ONLY
      "Prendi $+1 da $+2."
  END VERB.

END ADD TO OBJECT.

SYNONYMS
    dalla, dallo   = da. -- dalla (fem.sing.) | dallo (masc.sing.)
    dalle          = da. -- dalle (fem.plur.)

    'dall''', dall = da. -- dall' / dall (masc.sing.)*
--| * " dall " is not correct Italian, but a workaround to the limitation mentioned above.

--  dai = da.            -- dai (masc.plur.) | CAN'T BE USED AS ALTERNATIVE because
--|                                            of conflict with 'dai' verb:
--| 333 E : The word 'dai' is defined to be both a synonym and another word class.

--------------------------------------------------------------------------------

Start at lounge.