0

我们已经定制了我们的 Trac 实例以向newticket 页面显示其他内容,并使用以下site.html文件(如文档中所述):

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

我在文档中没有看到任何关于翻译的内容。我们现在如何翻译这段文字?

4

2 回答 2

2

不幸的是,在实现自定义标签的提议之前,这并不容易。

目前,它需要将您的附加 msgids 添加到 Trac 核心 PO 文件并重新编译和安装该自定义 Trac 版本 - 非常丑陋,并且不像模板那样可远程修改。

在插件中提供自定义翻译不会有效,因为插件翻译将驻留在翻译域中,不会针对 Trac 核心模板(如(新)工单页面)进行评估。

于 2014-08-17T23:25:43.953 回答
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>
于 2014-10-18T01:34:38.567 回答