Actions

Developer Area/Language Pack Generation

From Mahara Wiki

< Developer Area

Two scripts in the mahara-langpacks directory of the mahara-scripts repository keep the Mahara translations up to date:

  1. update-pot.sh polls the Mahara code for changes to strings, and pushes those changes to the mahara-lang project in launchpad
  2. langpacks.sh polls the mahara-lang repositories on launchpad, and generates official mahara language pack tarballs at http://langpacks.mahara.org.

mahara-scripts also has a debian/ directory, which creates a package called custom-site-mahara-langpacks_x.y_all.deb. This package installs the above scripts and their dependencies, and sets them up to run on cron.

The following is a general summary of what these scripts are trying to do. Obviously, to fix bugs or find out what's really going on, you need to read them.

Generation of .pot files for launchpad

  • The update-pot.sh script runs once a day as the maharabot user
  • Checks current branches at git://gitorious.org/mahara/mahara.git for updates
  • If there have been changes, runs a php script called php-po.php to generate a single mahara.pot file (for each branch) from the en.utf8 directories in the mahara working tree
  • On the master branch, it may also create po files for existing translations, when there have been changes to Mahara strings that don't need to be translated (e.g. typos)
  • Pushes updated pot and po files to lp:~mahara-lang/mahara-lang/<branch>, where they will be imported into launchpad ready for translation

The package takes care of most of the necessary dependencies except for the maharabot user's ssh key, needed for the bzr push to launchpad. That still needs to be installed manually on the server.

Generation of language packs

  • The langpacks.sh script runs once per hour as the maharabot user
  • Checks all the languages in the language-repos.txt file for newly translated strings. This file is pulled straight from gitorious each time the script runs, so to add a new language, you only need to commit this file, you do not need to update the package or copy the file to the server.
  • For each language and each current mahara branch, there is a single .po file exported by launchpad*
  • The last commit id for each language/branch is stored in the file /var/lib/mahara-langpacks/tarballs/mahara-langpacks.last (in the script's working directory). If you ever need to force regeneration of a particular language pack, you probably need to hack that file to remove the language and/or branch.
  • The script po-php.pl converts the .po file into the directory tree of php and html files required by Mahara
  • Tarballs of these directories are put into the document root of the http://langpacks.mahara.org site, and index.html, status.html files are generated

Manually update language packs

If you are in charge of mahara translation management, you can manually update language packs on [1]. This is the case where the langpack scripts can not be run on the server.

  • You should have permission to access the langpacks.mahara.org server.

Here are the instructions

  • Update environment variables in /etc/mahara-langpacks.conf
  • Run the script update-pot.sh
  • Run the script langpacks.sh
  • Copy the directory mahara-langpacks to the server
    • Use 'scp' to copy the langpacks directory from your local machine to a temporary directory on the server.
    • Use 'sudo -u maharabot cp -ar ...' to copy to the langpacks directory.

Manually create a tar ball of a language for testing

You can generate the language pack of a particular language to test. Here are the instructions

mkdir ~/code
cd ~/code
git clone =git://gitorious.org/mahara/mahara-scripts.git
  • Get the po file of the language from Launchpad
  • Run the script po-php.pl
cd mahara-scripts/mahara-langpacks
po-php.pl /path/to/po/files/<po file> /path/to/langpacks/<language code>.utf8 <language code>.utf8
  • Build the tar ball
cd /path/to/langpacks
tar -czf <language code>-master.tar.gz <language code>.utf8

* There is still a lot of code for the old gitorious language repos that can go away if/when the last gitorious translations finally die.