Developer's Guide to KHangMan
Prev
Next

Chapter 5. Developer's Guide to KHangMan

How to add words in a new language for the game

Thanks to Stefan Asserhäll, it is very easy to add a new language directly to the game. The procedure described here can also be found in the khangman source folder in the file README.languages. Please follow the procedure and then send me the files tarred and gzipped to annemarie.mahfouf@free.fr.

The twenty four available languages so far by code are: bg ca cs da de en es fr fi ga hu it nb nl nn pt pt_BR ru sl sr sr@Ltn sv tg and tr. If your language code is not among those, you can proceed further.

Most of this data should be completed to include hints, please see below. Complete data: bg de fr en it only have hints so the other above languages must be updated as soon as possible.

Be sure you are working with the latest svn trunk sources of KHangMan by issuing a


svn up khangman
in the kdeedu module. Then

cd kdeedu/khangman

The words are stored in 4 separate files, one for each level. The files are in /khangman/data/en. The file easy.txt is for level easy, the file medium.txt is for level medium, the file animals.txt is for level animals and the file hard.txt is for level hard.

English is the default and thus the only language to be shipped with KHangMan. All other languages data are put in the correct kde-l10n.

  1. Enter the following commands in a Konsole to create the folder and files for the new language:

    ./add_language language_code

    Here you must replace language_code with your language code.

  2. The files now use the kvtml format. The tag <o> is for the word and the tag <t> is for the hint. Try to match the hint with the level of difficulty. The level 'Easy' will require an easy hint but the level 'Hard' will require the definition in the dictionary. Try not to use words of the same family in the hint, that would give the word away too easily!

    An example of a kvtml file is as follow:

    
    	<?xml version="1.0"?> 
    	<!DOCTYPE kvtml SYSTEM "kvoctrain.dtd"> 
    	<kvtml> 
    	<e> 
    	<o>cane</o> 
    	<t>è il tuo animale domestico preferito</t> 
    	</e> 
    	...
    	...
    	</kvtml>
    
  3. Edit all indicated text files in the new folder with a text editor, and replace each word inside the <o> tag with a translated word and each hint inside a <t> with a translated hint. It is not really important that the exact meaning is preserved, but try to keep the length and level of difficulty roughly the same. You can include words with white space or - in them, in that case the white space or the - will be shown instead of the _. Please contact Anne-Marie Mahfouf if there is anything special related to your language so I can adapt the code to it (especially the special and accented characters).

    You can just translate the words but you can also adapt them following the level and add new words if you want. For example, “table” is in level easy in English but in your language, it can be level medium. Feel free to adapt the files to your language needs. The number of words in a file is not important, you can add some if you want.

    Remember that all words are nouns.

    Note that you must use UTF-8 encoding when editing the files. If your editor cannot do this, try using KWrite or Kate. When opening a file in KWrite or Kate you can select utf8 encoding with the combo box at the top of the file open dialog.

    Please keep the actual English filenames in your language_code dir.

  4. Enter the following command to install the new data files:

    make
    make install

    You may have to become root to run make install, depending on your installation.

  5. Run the game and check that your language has been added:

    khangman
  6. Instead of committing your files, please sent them to Anne-Marie Mahfouf tarred and gzipped. As there are now twenty three languages, a wizard (KNewStuff) is now included in KHangMan to easily download and install new languages that are placed on the website. This is done to reduce the size of the kdeedu module and it will also be done in KLettres, KStars and maybe KTouch. Please contact Anne-Marie by email if you need further information.

    When you send me the files, please don't forget to mention any special characters used in your language (put them in a text file, one per line and add this file in the tarball) and please mention any other specificity.

    Please never commit files in a BRANCH as it might break the game.

Many thanks for your contribution!

Prev
Next
Home


Would you like to make a comment or contribute an update to this page?
Send feedback to the KDE Docs Team