How
to localize the strings of a Firefox extension
Sometimes the extensions we translate have no locale folder, so we have to fumble here and there looking for strings... But we can all the same create a "locale" folder which will be useful to translators and to spread the extension worldwide... Let
us take the extension anidisable
by Harry Patsis as an example
|
|
|
1
Open
anidisable.xpi
|
![]() |
|
2
The chrome folder includes another zipped file that we open too... |
![]() |
|
3
Bad luck ! There is no locale folder in ... |
|
|
4
Well
then...
we just create one ! |
![]() right-click
on "New folder" then rename
|
|
5
And
we insert the following contents :
one en-US subfolder (supposing we are making an english locale of course) with these two files inside : -
anidisable.dtd
- contents.rdf |
![]() right-click
on "New text file" then rename
|
6
Now let us have a look in the file content/anidisable.xul, we are discovering strings to localize. These are words that will be displayed to the final user. Notice : we shall leave the word "Anidisable" untranslated, because it is recommended to leave the extension name as it is. |
Open with a
text-editor such as Pspad
or Jedit
![]() ... Which text strings can we localize ? Click here for tips |
7
This
is the important step !
Now we are about to replace messages between brackets by : & followed by a sufficiently explicit variable name, ending with a ; |
|
8
Now let us go in the en-US locale, in the anidisable.dtd file. With much care for the syntax (see example on the right), here we put variables names and their english "equivalent" . |
![]() |
9
Let's go back to the anidisable.xul file, and right on the second line we add this line that tells the extension the precise address where to find localized elements... |
|
10
We
make the same operation again - variables substitutions- for the
strings in the file :
anidisablesettings.xul
following the steps
7
8
9 |
![]() ...and
do not forget UTF-8 encoding !
|
|
11
See
below what is to write in the locale/ contents.rdf
file.
It
is the same for every extension, except of course for the extension
name itself.
To spare you the pain of
writing down the whole thing, you can just copy/paste from
this plain
text file....
|
|
![]() |
|
|
12
Another important point : if we want the extension to take our locale folders into account, you must indicate the address right from the beginning and add this yellow line in the install.rdf
file.
|
|
|
It is done ! All you've
got to do now is :
In this last version, the initial description is localized too : see how to do it here . And if you wish to localize strings included in a javascript (*.js) file, it is there. |
|
|
Which text
strings can we localize ?
Those which follow
these tags :
|
![]() |