## msc - Message Catalog

### Module Description

The msc module implements a message catalog. The catalog is used to translates a message to another message. It can be used for internationalization of messages and for converting messages. Use the [gmo] module for importing gettexts mo-files in a message catalog.

### Module Words

#### Catalog structure

msc% ( -- n )
  Get the required space for a message catalog

#### Catalog creation, initialisation and destruction

msc-init ( msc -- )
  Initialise the catalog
msc-(free) ( msc -- )
  Free the catalogs nodes from the heap
msc-create ( "<spaces>name" -- ; -- msc )
  Create a named message catalog in the dictionary
msc-new ( -- msc )
  Create a message catalog on the heap
msc-free ( msc -- )
  Free the message catalog from the heap

#### Catalog words

msc-add ( c-addr1 u1 c-addr2 u2 msc -- )
  Add the message c-addr1 u1 and translation c-addr2 u2 to the catalog
msc-translate ( c-addr1 u1 msc -- c-addr2 u2 )
  Translate the message c-addr1 u1 with the catalog, return message if not found
msc-translate? ( c-addr1 u2 msc -- c-addr2 u2 true | false )
  Translate the message c-addr1 u1 with the catalog, return success
msc-remove ( c-addr u msc -- flag )
  Remove the message c-addr u from the catalog, return success

#### Inspection

msc-dump ( msc -- )
  Dump the message catalog

### Examples

    include ffl/msc.fs

    \ Example 1 : translation of english to dutch

    \ Create the message catalog in the dictionary

    msc-create en>nl

    \ Add translations to the catalog

    s" yes"  s" ja"    en>nl msc-add
    s" no"   s" nee"   en>nl msc-add
    s" tree" s" boom"  en>nl msc-add
    s" bike" s" fiets" en>nl msc-add

    \ Translate messages

    s" yes"   en>nl msc-translate type cr
    s" bike"  en>nl msc-translate type cr
    s" house" en>nl msc-translate type cr     \ if not in the catalog, the orignal message is returned

    \ Example 2 : entity references in html

    \ Create the message catalog on the heap

    msc-new value entity

    \ Add the references in the catalog

    s" lt"   s" <"                   entity msc-add
    s" gt"   s" >"                   entity msc-add
    s" amp"  s" &"                   entity msc-add
    s" quot"  char " pad c!  pad 1   entity msc-add

    \ Convert the references

    s" lt"   entity msc-translate type cr
    s" quot" entity msc-translate type cr

    \ Free the catalog from the heap

    entity msc-free

generated 03-Jun-2010 by ofcfrth-0.10.0