我们已自定义Trac实例以显示newticket page的其他内容,并显示以下site.html
文件(如documentation中所述):
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
py:strip="">
<form py:match="div[@id='content' and @class='ticket']/form[@action='/newticket#ticket']" py:attrs="select('@*')">
<div class="warning">
<p>You are about to create a new JOSM ticket.
</p>
<p>Please make sure to always use this link in <a href="wiki/Help/Action/About">About Dialog</a> (Shift-F1) to come here:</p>
<img src="raw-attachment/wiki/Help/Action/About/bugreport_small.png" alt="Bug report link in About dialog" height="53" width="361" />
<p>Clicking on this link prefills the bug report with useful information for us (<a href="wiki/Help/Action/ShowStatusReport">Status Report</a>).
</p>
<p>In any case, don't be shy :) Please let us a way to contact you if needed (either by <a href="register">creating an account</a> or entering your e-mail address below (it won't be publicly visible but will allow us to reach you, and you will be notified about ticket progress).
</p>
</div>
${select('*')}
</form>
</html>
我在文档中没有看到任何关于翻译的内容。我们现在如何翻译这个文本?
答案 0 :(得分:2)
不幸的是,在proposal for custom labels之类的东西被实现之前,这并不容易。
目前,它需要将其他msgids添加到Trac核心PO文件并重新编译和安装该自定义Trac版本 - 非常难看,并且不像模板那样可以远程修改。
在插件中提供自定义翻译效果不高,因为插件翻译将驻留在翻译域中,而不会对(新)故障单页面等Trac核心模板进行评估。
答案 1 :(得分:0)
我终于想出了一个小型的JavaScript解决方案。
当您只需要几种语言且文本不会改变时,这很简单:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
py:strip="">
<form py:match="div[@id='content' and @class='ticket']/form[@action='/newticket#ticket']" py:attrs="select('@*')">
<div class="warning">
<table style="border:0; border-collapse:separate; border-spacing:0 10px" class="wiki">
<tr><td style="background:#FFFC75; border:1px solid #ccc; border-right:0" valign="top">
<p id="josm_warning_01">You are about to create a new JOSM ticket.
</p>
<p id="josm_warning_02">Please make sure to always use <a href="wiki/Help/Action/ReportBug">Help/Report bug</a> or this link in <a href="wiki/Help/Action/About">About Dialog</a> (Shift-F1) to come here:</p>
<img src="raw-attachment/wiki/Help/Action/ReportBug/reportbug.png" alt="Bug report menu entry" height="84" width="207" />
<img src="raw-attachment/wiki/Help/Action/About/bugreport_small.png" alt="Bug report link in About dialog" height="53" width="361" />
</td></tr>
</table>
</div>
<script type="text/javascript">
if (navigator.language.indexOf('fr') == 0) {
document.getElementById("josm_warning_01").innerHTML = 'Vous êtes sur le point de créer un nouveau ticket JOSM.';
document.getElementById("josm_warning_02").innerHTML = 'S\'il vous plaît, assurez-vous de toujours utiliser <a href="wiki/Help/Action/ReportBug">Aide/Rapporter un bug</a> ou ce lien dans la <a href="wiki/Help/Action/About">fenêtre À propos</a> (Shift-F1) pour venir ici:';
} else if (navigator.language.indexOf('de') == 0) {
document.getElementById("josm_warning_01").innerHTML = 'Sie sind dabei, ein neues JOSM-Ticket zu erstellen.';
document.getElementById("josm_warning_02").innerHTML = 'Bitte nutzen Sie immer <a href="wiki/De:Help/Action/ReportBug">Hilfe → Fehler melden</a> oder diesen Link im <a href="wiki/De:Help/Action/About">"Über JOSM..."-Fenster</a>, um hierher zu gelangen:';
}
</script>
${select('*')}
</form>
</html>