2012-12-13 71 views
1

我正在使用pootle来允许人们在PHP Yii项目中翻译.po文件。git sparsecheckout - 如何拉入不同的目录

一旦翻译者更新.po文件,Pootle可以拉和翻译翻译。 另外我们有开发人员在网站上工作,他们也可能会更新翻译文件以添加更多要翻译的文本。

Yii的要求.po文件必须位于:

警予项目/保护/消息/ EN_GB/messages.po

Pootle需要的目录结构为:

pootle /警予项目/ EN_GB/messages.po

为了让pootle执行&推送,.git目录需要位于pootle/yii-project/.git中。

我已经尝试使用git稀疏结帐,但是这会将文件拉入pootle/yii-project/protected/messages/en_gb/messages.po,不幸的是pootle没有拿起。

我无法在其他地方执行资源库的拉取操作,然后软链接,因为pootle将无法找到.git目录。

我真的很希望能够做的是一个目录的稀疏结账,结果映射到另一个目录,即结账:

pootle /警予项目/保护/消息/ - > pootle/yii-project

我不想使用git-subtree,因为我希望能够由开发人员或翻译人员更新文件。我不想使用子模块,因为我不喜欢额外的拉开开销,并且我们希望开发人员在一次提交中包含对新功能所做的所有更改(而不是主项目上的一次提交以及一个在子模块上)。

有什么建议吗?

+0

是否有可能将这些目录中的一个链接到另一个目录? – mgarciaisaia

+0

@ desert69 - 不幸的是,.git目录需要在pootle/yii-project中才能被pootle使用。如果我将pootle/yii-project软链接到yii-project/protected/messages /,pootle将无法找到.git目录 – dastra

+0

Pootle对Git和不同工作流的支持不足是我编写Weblate的原因之一,所以你可以考虑使用它。请参阅http://weblate.org/ –

回答

0

我们找不到使用git sparsecheckout的解决方案。

相反,我们使用子模块。

我们首先提取了yii-project/protected/messages目录,并创建了一个名为yii-project-translations的新存储库。

然后,我们小写每个目录包括翻译的 - 例如:

git mv en_GB en_gb 

我们遂把新的存储库放回原警予项目作为一个子模块:

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 

并克隆此库作为pootle项目:

cd $POOTLE_HOME/translations/ 
git clone [email protected]:yii-project-translations yii-project 

Final LY,我们在pootle数据库小写目录名更新几个表,所以一切都绑在一起罚款:

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); 

@米哈尔 - cihar - Weblate看起来极好。如果我在我们沿​​着小路途径获得90%之前遇到它,我会使用它。谢谢!