7.3. Localizing The Templates

Currently, these templates contain code and localizable strings mixed together that makes the localization of Bugzilla a bit difficult. What is to be localized and what is not?

IMPORTANT: Use an UTF8 compliant editor like Gedit, Kate or Emacs under GNU/Linux systems or Notepad++ under Windows systems and localize the templates using UTF8 encoding. You can also use Komodo Edit which has great syntax highlighting for Template Toolkit files.

Here are some examples to help you localizing the right stuff. A good idea is to start with the localization of /template/en/default/global/variables.none.tmpl. This file contains several terms that will be substituted all around the templates files. You can see in this file lines like these:

[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  #
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
  #%]

DO NOT translate text located between [%# and #%]: the text inside is comment.

[% terms = {
  "bug" => "bug",
  "Bug" => "Bug",
  "abug" => "a bug",
  "Abug" => "A bug",
  "ABug" => "A Bug",
  "bugs" => "bugs",
  "Bugs" => "Bugs",
  "zeroSearchResults" => "Zarro Boogs found",
  "bit" => "bit",
  "bits" => "bits",
  "Bugzilla" => "Bugzilla"
  }
%]

DO NOT translate terms here. What is to be translated here, is the word between the quotes after =>, as highlighted in red above.

These terms will be used in the templates. Whenever you see expressions like &terms.ABug or &terms.bugs in templates, they will be replaced in the user interface with the value you put in this file.

Another file that is used by several templates is /template/en/default/global/field-descs.none.tmpl. You can see there lines like these:

[% IF in_template_var %]
  [% PROCESS "global/value-descs.none.tmpl" %]
  [% SET vars.value_descs = value_descs %]
  [% SET vars.terms = terms %]

  [%# field_descs is loaded as a global template variable and cached
    # across all templates--see VARIABLES in Bugzilla/Template.pm.
    #%]
  [% vars.field_descs = {
    "[Bug creation]"          => "[Date de création du $terms.bug]",
    "actual_time"             => "Heures actuelles",
    "alias"                   => "Alias",
    "assigned_to"             => "Responsable",

DO NOT translate here PROCESS or USE. As a general rule, never translate capitalized words enclosed between [% and %]. As previously, translate the word after the =>.

Now, you can start translating the other templates. Some other examples of what needs to be translated:

[% title = BLOCK %]Delete Component '[% comp.name FILTER html %]'
of Product '[% product.name FILTER html %]'
  [% END %]

[% PROCESS global/header.html.tmpl
  title = title
%]

<table border="1" cellpadding="4" cellspacing="0">
<tr bgcolor="#6666FF">
  <th valign="top" align="left">Field</th>
  <th valign="top" align="left">Value</th>
</tr>

Localized template:

[% title = BLOCK %]Supprimer le composant « [% comp.name FILTER html %] »
du produit « [% product.name FILTER html %] »
  [% END %]

[% PROCESS global/header.html.tmpl
  title = title
%]

<table border="1" cellpadding="4" cellspacing="0">
<tr bgcolor="#6666FF">
  <th valign="top" align="left">Champ</th>
  <th valign="top" align="left">Valeur</th>
</tr>

You will encounter many buttons you will want to localize. These are looking like this:

  <input type="submit" id="create" value="Add">
  <input type="hidden" name="action" value="new">
  <input type="hidden" name='product' value="[% product.name FILTER html %]">
  <input type="hidden" name="token" value="[% token FILTER html %]">

Whenever you see this, the only line that needs to be localized is the one with type="submit". DO NOT translate lines with type="hidden":

  <input type="submit" id="create" value="Ajouter">
  <input type="hidden" name="action" value="new">
  <input type="hidden" name='product' value="[% product.name FILTER html %]">
  <input type="hidden" name="token" value="[% token FILTER html %]">

Other common lines through the templates are text enclosed between an opening and a closing tag:

<td valign="top">Description du produit :</td>

<td valign="top">[% IF product.disallow_new %]Oui[% ELSE %]Non[% END %]</td>

  <a title="Liste des [% terms.bugs %] pour le composant « [% comp.name FILTER html %] »"
     href="buglist.cgi?component=[% comp.name FILTER url_quote %]&product=
          [%- product.name FILTER url_quote %]">[% comp.bug_count %]</a>

This documentation undoubtedly has bugs; if you find some, please file them here.

Previous topic

7.2. Files To Be Localized

Next topic

7.4. Caveats