Developer Area/Language Pack Generation

From Mahara Wiki

< Developer Area
Revision as of 15:15, 16 May 2012 by Richard (talk | contribs) (Created page with "Two scripts in the mahara-langpacks directory of the [ mahara-scripts repository] keep the Mahara translations up to date: # update-pot…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

  1. polls the Mahara code for changes to strings, and pushes those changes to the mahara-lang project in launchpad
  2. polls the mahara-lang repositories on launchpad, and generates official mahara language pack tarballs at

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 script runs once a day as the maharabot user
  • Checks current branches at 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 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 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 site, and index.html, status.html files are generated

* 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.