# How to translate Moregroupware

This document describes the way of localize moregroupware or special modules of moregroupware. It should give the reader the chance to add a complete new language to moregroupware or to a module within the moregroupware framework.

## Structure of Moregroupware

The graphic below demonstrates the directory structure of moregroupware. On the first level you have the modules, in the shown tree you can see the module "admin"; and the module "calendar". There are also some folders which are on the first level which are not a module but other application based directories, but thats not the focus of the document. We will use the "calendar" module for a detailed explanation:

### Moregroupware Tree

The lang folder contains language files for a certain language.

A moregoupware language file has the following file name: `m.x.lang`, where m = module name, x = international language code.

Each module has this language structure, or at least, it must have it to be moregroupware compliant.

## Moregroupware lang-file

The Moregroupware language file conists of 2 parts, the key and the text. The parts are seperated by an equal (=) sign. Below is a simple example of an english and a german language file:

english lang-file from calendar module (calendar.en.lang)

    collisionwith = collision with
          date = Date
          dateconflict = dateconflict
          desc = Description
          dobook = book

german lang-file from calendar module (calendar.de.lang)

    collisionwith = kollidiert mit
          date = Datum
          dateconflict = Terminkonflikt
          desc = Beschreibung
          description = Beschreibung
          dobook = buchen

As you can see only the right side of the "=" sign will be modified. So if you want to create a new language file for a module or for all modules, you must copy an existent lang file you understand (i assume english) to a new file named calendar.it.lang, if you want to translate to italien, or to calendar.ru.lang if you want to translate to russian. Then modify the file and edit the text on the right of the "=" sign on each line.

### Using newslines for long text

As you can see, this is not very comfortable for long texts, because you may have to scroll to the right if you have two or more sentences. Because of this you can insert newline and continue your text on the next line, the following example demonstrates this:

    collisionwith = collision with
            another appointment, and this is not all. There was also a collision with my
            car the morning before, but this is only important to mention because
            i want to insert a really long text for the keyword collisionwith
            date = Date

You can see that the key "collisionwith" has a very long text and in fact it doesnt matter, moregroupware will handle this situation without any problems.

### Variables inside lang files

The moregroupware framework is capable of having variables inside text. This is very important because when moregroupware wants to display something like: "User Thomas Smith found 10 Contacts from 122", the text consists of normal text which must be translated and of variable parts like username (Thomas Smith) and records found (10 and 122). In order to handle this, the lang file can look like the following example:

    myheader = User <$1> found <$2> Contacts from <$3>

or the german one:

    myheader = Benutzer <$1> hat <$2> Kontakte von <$3> gefunden

Here you can see that moregroupware has no problems with different sentence structures, because you can place the variables wherever you want.

## Test new language

If you have sucessfully translated a module for moregoupware, which means you have added a new file for example "calendar.it.lang" (italian) to the lang directory of a module (calendar). You can check out your translation by following the steps below:

- run following SQL against your moregroupware database:

- INSERT INTO `mgw_languages` (`langcode`, `description`, `active`, `lu_user`, `lu_date`) VALUES ('it', 'Italian', '1', 'admin', NOW())

- open moregroupware and go to "settings" and "personal settings"

- change your language to the one you just created (here italian)

- go to your translated module and check the results

## Common Errors

There are some things to mention when localizing moregroupware. These problems will not remain for years, but at the moment, you must watch out for the following:

### When adding a completely new language...

your first module translation should be "settings". Because when you add a new language and you translate only a module like calendar, moregroupware will fail in the same second when you switch your personal language to the new one. This is because the switching itself occurs in the module "settings" and before you have the chance to change to your translated module, moregroupware will search for a translation of "settings".