Chapter 4. Developer's Guide to KHangMan

How to translate words in a new language for the game

Please follow the procedure and then send the files tarred and gzipped to the kde-edu mailinglist.

Please have a look in KHangMan in the top toolbar to see if your language is available yet. If it is, then you can check if it contains hints.

The standard list words are stored in 4 separate files, so to make different categories. The files are in /khangman/data/. The file easy.kvtml is for category easy, the file medium.kvtml is for category medium, the file animals.kvtml is for category animals and the file hard.kvtml is for category hard.

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

  1. The files use the kvtml format. The tag <text> is for the word and the tag <comment> is for the hint, those are within a <entry> tag. Please try to match the hint with the category of difficulty. The category Easy will require an easy hint but the category 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!

    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.

    An example of a kvtml file is as follow:

    <?xml version="1.0"?> 
    <DOCTYPE kvtml PUBLIC "kvtml2.dtd"
    <kvtml version="2.0"> 
        <title>Animals</title><!--Translate tag content-->
        <comment>Animals from across the
    planet</comment><!--Translate tag content-->
        <identifier id="0" >
    <entry id="0" >
          <translation id="0" >
            <text>bear</text><!--Translate all text tags
            <comment>Large heavy animal with thick
    fur</comment><!--Translate all comment tags content-->
  2. At the beginning of the file, you should translate the content of the <title> and the <comment> tags which are within the <information> tag. The title will be the one that will appear in the Category menu of the game (where the user chooses the file to play with).

  3. Then within the <identifier> tag, please put your language code instead of en in <locale>.

    Please don't translate the file name itself as filenames should never contain any special characters. Thus please save your file with the same English filename.

  4. Edit the kvtml files with a text editor (it will be easier if you use the XML syntax highlighting) and replace each word inside the <text> tag with a translated word and each hint inside a <comment> with a translated hint. It is not really important that the exact meaning is preserved, but try to keep the length and category 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 the kde-edu mailinglist if there is anything special related to your language so I can adapt the code to it (especially the special and accented characters).

  5. You can just translate the words but you can also adapt them following the category and add new words if you want. For example, table is in category easy in English but in your language, it can be category 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.

  6. You can then commit your files in l10n-kf5/<lang_code>/data/kdeedu/kdeedu-data/. Do not forget to update the CMakeLists.txt file as well. Please contact the kde-edu mailinglist if you need further information. When you send the files, please do not 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!