以方便的方式翻译Kohana模块吗? [英] Translating Kohana-modules in a convenient way?

查看:74
本文介绍了以方便的方式翻译Kohana模块吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一种方便的方式来制作和维护我的Kohana模块的翻译.我玩过POEdit,并从我的模块中提取了所有__().就像POedit的工作方式一样,它只是运行一个快速更新以收集所有新字符串并在以后保存新目录.之后,我可以将po文件转换为PHP数组的种类……似乎所有步骤都有些复杂.

I have been looking for a convenient way of making and maintaining translations of my Kohana-modules. I have played around with POEdit and have extracted all __()'s from my modules. Really like the way POedit works, and it's just to run a quick update to gather all new strings and save a new catalog later on. I could afterwards convert the po-files to PHP-arrays sort of...it seems a bit complicated with all steps.

我看过这种方法,但是我宁愿不安装表格和新模块进行翻译,我认为这会变得复杂且愚蠢";-).

I have seen this approach but I would rather not install tables and new modules for translations, I think this gets to complicated and "drupalish" ;-).

您如何在Kohana项目中管理不同语言的本地化和翻译?任何提示将不胜感激!

How do you managing localizations and translations on different languages in your Kohana-projects? Any hints would be much appreciated!

推荐答案

这就是我的方法.不幸的是,首先,Mac版POEdit的错误和怪异.

This is how I did it. First of all POEdit for Mac is very buggy and strange, unfortunately.

在POEdit中,使用正确的路径和__作为关键字创建了一个新目录.

In POEdit, created a new catalog with correct path and __ as a keyword.

运行POEdit提取所有字符串.

Run POEdit to extract all the strings.

此后,我在生成的PO文件上运行了这个简单的PHP脚本.我将脚本的输出粘贴到项目的i18n文件夹中的文件中.

After this I ran this simple PHP-script over the generated PO-file. The output from the script I pasted into the files in i18n-folder of the project.

$file = 'sv_SE.po';
$translations = array();
$po = file($file);
$current = null;
foreach ($po as $line) {
    if (substr($line,0,5) == 'msgid') {
        $current = trim(substr(trim(substr($line,5)),1,-1));
    }
    if (substr($line,0,6) == 'msgstr') {
        $translations[$current] = trim(substr(trim(substr($line,6)),1,-1));
    }
}

echo "<?php\n\n";
foreach ($translations as $msgid => $msgstr) {
    echo '\'' . $msgid . '\' => \'' . $msgstr . "',\n";
}
echo "\n?>";

通过使用POEdit,可以轻松地维护项目本地化,因为它可以同步所有字符串,而只需单击更新"即可.我将获得有关新旧字符串的报告,并且可以在短时间内更新本地化.希望它能对某人有所帮助.

By using POEdit it's easy to maintain the project-localizations since it's syncing all the strings but just clicking "Update". I'll get a report of new and obsolete strings and can update the localizations in a few moments. Hope it helps someone.

这篇关于以方便的方式翻译Kohana模块吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆