1

I'm using pootle to allow people to translate the .po files in a PHP Yii project.

Pootle can pull and push translations once a translator has updated the .po file. Separately we have developers working on the site, who may also update the translation files to add more text to be translated.

Yii requires the .po files to be located in:

yii-project/protected/messages/en_gb/messages.po

Pootle requires the directory structure to be:

pootle/yii-project/en_GB/messages.po

In order for pootle to pull & push, the .git directory needs to be in pootle/yii-project/.git.

I have tried using git sparse checkout, but that will pull the files into pootle/yii-project/protected/messages/en_gb/messages.po which unfortunately pootle does not pick up.

I can't do a pull of the repository elsewhere and then softlink, as then pootle will not be able to find the .git directory.

What I would really like to be able to do is a sparse checkout of a directory and map the result to another directory, i.e. checkout:

pootle/yii-project/protected/messages/ -> pootle/yii-project

I don't want to use git-subtree, as I want the files to be able to be updated either by the developers or the translators. I don't want to use submodules, as I don't like the extra pull overhead, and we would like the developers to include all changes to do with a new feature in a single commit (instead of one commit on the main project and one on the submodule).

Any suggestions?

morten.c
  • 3,414
  • 5
  • 40
  • 45
Dan Straw
  • 221
  • 2
  • 4
  • Is it a possibility to make one of those directory a link to the other? – mgarciaisaia Dec 14 '12 at 13:01
  • @desert69 - unfortunately the .git directory will need to be in pootle/yii-project for pootle to pick it up. If I softlink pootle/yii-project to yii-project/protected/messages/, pootle won't be able to find the .git directory – Dan Straw Dec 15 '12 at 13:22
  • Poor support of Git and different workflows in Pootle was one of my reasons for writing Weblate, so you might consider using it instead. See http://weblate.org/ – Michal Čihař Dec 20 '12 at 10:43

1 Answers1

0

We couldn't find a solution using git sparsecheckout.

Instead, we used submodules.

We first extracted the yii-project/protected/messages directory, and created a new repository called yii-project-translations.

We then lowercased each of the directories including translations - for instance:

git mv en_GB en_gb

We then included the new repository back into the original yii-project as a submodule:

cd yii-project/
git subtree split --prefix=protected/messages --branch=yii-project-translations
cd protected/
git rm -rf ./messages
mkdir messages
pushd messages
git init
git remote add origin git-server:yii-project-translations
git pull ../../ yii-project-translations
git push origin -u master
popd

And cloned this repository as the pootle project:

cd $POOTLE_HOME/translations/
git clone gitolite@git.algo.travel:yii-project-translations yii-project

Finally, we updated several tables in the pootle database to lowercase directory names, so everything tied together fine:

update pootle_app_language set code = lower(code);
update pootle_app_directory set pootle_path = lower(pootle_path);
update pootle_app_translationproject set real_path = lower(real_path), pootle_path = lower(pootle_path); 

@michal-cihar - Weblate looks excellent. If I'd come across it before we'd got 90% along the pootle path I would have used that. Thanks!

Dan Straw
  • 221
  • 2
  • 4