Actions

Developer Area/Language Packs/Structure: Difference between revisions

From Mahara Wiki

< Developer Area‎ | Language Packs
No edit summary
(link to launchpad translation ui)
Line 1: Line 1:
'''Translations are now mostly done via a new [https://translations.launchpad.net/mahara-lang web interface].'''
There are several types of Mahara plugins that can hold their own translation. They are defined in a function plugin_types(), see lib/mahara.php. At the time of writing this, seven plugin types are known:
There are several types of Mahara plugins that can hold their own translation. They are defined in a function plugin_types(), see lib/mahara.php. At the time of writing this, seven plugin types are known:



Revision as of 12:47, 29 March 2012

Translations are now mostly done via a new web interface.

There are several types of Mahara plugins that can hold their own translation. They are defined in a function plugin_types(), see lib/mahara.php. At the time of writing this, seven plugin types are known:

  • artefact
  • auth
  • blocktype
  • grouptype (new in 1.1)
  • interaction
  • notification
  • search

Every plugin type has got its own directory in the root of Mahara htdocs. Within these root directories, individual plugins have their own subdirectories, eg:

  • htdocs/artefact/blog/
  • htdocs/artefact/file/
  • htdocs/auth/ldap/
  • htdocs/interaction/forum/

Every plugin defines its own strings in the English language file. This is located within 'lang/en.utf8' subdirectory of the plugin, eg:

  • htdocs/artefact/blog/lang/en.utf8/artefact.blog.php
  • htdocs/artefact/file/lang/en.utf8/artefact.file.php
  • htdocs/auth/ldap/lang/en.utf8/auth.ldap.php
  • htdocs/interaction/forum/lang/en.utf8/interaction.forum.php

As you can see, string files are spread around the source code tree (compare to Moodle approach where all string files are centralized into the /lang directory). The strings used by the Mahara core itself are defined in the folder

  • htdocs/lang/en.utf8/

One of the files defined there is the language configuration file langconfig.php.

There are two possible ways  to store your translation string files: having the language pack stored in a separate folder-langpacks-, out the Mahara code tree, or having each of the language string files stored next to the English ones, at the pluggin level. The dominant tendency among Mahara translators is the first one- installing the language pack in a separate langpack folders, which makes easier the code upgrades.

In the following text, let us expect your language code is xx. Replace xx with the code of your language (eg. 'cs' for Czech, 'de' for Deutsch etc.).

1. Having language pack out of the Mahara source code tree

In this case, the whole hierarchy of all htdocs/type/plugin/lang/xx.utf8 folders is taken out of the Mahara source code tree and pasted into a separate location of your choice. There is a directory in Mahara's dataroot directory called 'langpacks' that can be used for this purpose without any configuration, as Mahara looks in there for directories matching *.utf8 to use as language packs. Given that you decide to have your language pack within maharadata/langpacks/xx.utf8 you will have string files in locations like

  • maharadata/langpacks/xx.utf8/artefact/blog/lang/xx.utf8/artefact.blog.php
  • maharadata/langpacks/xx.utf8/artefact/file/lang/xx.utf8/artefact.file.php
  • maharadata/langpacks/xx.utf8/auth/ldap/lang/xx.utf8/auth.ldap.php
  • maharadata/langpacks/xx.utf8/interaction/forum/lang/xx.utf8/interaction.forum.php
  • maharadata/langpacks/xx.utf8/lang/xx.utf8/langconfig.php

The structure of the folders within maharadata/langpacks/xx.utf8 has to correspond to the structure of the folders as would be in the first case described above. It means you can always move/copy your language pack from maharadata/langpacks/xx.utf8 into the standard Mahara source code tree.

If you want to have your language pack both out of the Mahara source tree and not within dataroot, you can use the configuration variable 'langpacksearchpaths' to add your own directories where language packs exist. You can set this in config.php by adding a line like so:

$cfg->langpacksearchpaths = array('/home/me/languagepacks/xx.utf8');

As you can see, this variable is an array, meaning you can add more than one path if necessary.

2. Having language pack at the plugin level

Warning: This information is only valid for earlier versions of Mahara, prior to 1.2

You can have your files "next to the English ones", ie.:

  • htdocs/artefact/blog/lang/xx.utf8/artefact.blog.php
  • htdocs/artefact/file/lang/xx.utf8/artefact.file.php
  • htdocs/auth/ldap/lang/xx.utf8/auth.ldap.php
  • htdocs/interaction/forum/lang/xx.utf8/interaction.forum.php
  • htdocs/lang/xx.utf8/langconfig.php

By this way, you can distribute your contrib plugins together with their translations bundled. On the other hand, from the translator's point of view, this leads to the situation that your Mahara installation is a mixture of a standard distribution tree with a lot of directories added by yourself. Of course, this makes the distribution of the whole language pack more difficult.