Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1/10
KOHATranslationTeam
Introduction
Note: It's assumed, in every example, that you have downloaded the file koha-2.x.tar.gz and that you have unpacked it in the 'home' directory of the 'user' user. Provided this, you should have a koha-2.x directory under /home/user/ In each system, directory and user names should be replaced accordingly.
KOHA internationalization can be achieved in several ways. Not so long ago, it was necesary to copy the entire /home/usuario/koha-2.x/intranethtml/intranet-tmpl/default/en directory into another (i.e. /home/usuario/koha2.x/intranet-html/intranet-tmpl/default/es) then manually edit each one of the templates contained in the newly created directory, translating the text strings they contain, trying, of course, not to touch or change anything else. Once the translation was finished, it was only necesary to configure KOHA's 'opaclanguages' System Preference to use the new language (i.e. es) This procedure works and has produced acceptable results but is, obviously, very slow and difficult. Now, thanks to KOHA's developer team, we have the tmpl_process3.pl script (provided with the KOHA distribution). In short, this script takes the file or directory that we want to translate (i.e. /home/usuario/koha-2.x/intranet-html/intranet-tmpl/default/en) and generates a single '.po' file (.po comes from Portable Object) containing only the text strings contained inside the KOHA's template files. This type of file is a format standard in the software internationalization work in te Free Software world and, because of this, there are several tools developed to edit them. The present tutorial aimes to show how to use the tmpl_process3.pl script to generate a '.po' file from KOHA's templates, introduce the use of one of the tools developed for '.po' files treatment (Kbabel) and then the use of the tmpl_process3.pl script again, to generate a set of translated templates for use in our KOHA installation.
2/10
KOHATranslationTeam
Example: user@host: cd /home/usuario/koha-2.x/scripts/misc/translator/ user@host: ./tmpl_process3.pl --help The previous command will produce, as output, a list of options and a little help about the script's usage, as shown below Usage: ./tmpl_process3.pl create [OPTION] or: ./tmpl_process3.pl update [OPTION] or: ./tmpl_process3.pl install [OPTION] or: ./tmpl_process3.pl --help Create or update PO files from templates, or install translated templates. -i, --input=SOURCE Get or update strings from SOURCE file. SOURCE is a directory if -r is also specified. -o, --outputdir=DIRECTORY Install translation(s) to specified DIRECTORY --pedantic-warnings Issue warnings even for detected problems which are likely to be harmless -r, --recursive SOURCE in the -i option is a directory -s, --str-file=FILE Specify FILE as the translation (po) file for input (install) or output (create, update) -x, --exclude=REGEXP Exclude files matching the given REGEXP --help Display this help and exit The -o option is ignored for the "create" and "update" actions. Try `perldoc ./tmpl_process3.pl' for perhaps more information. To create a 'circ_es.po' containing the text strings of the english templates located in the 'circ' directory of the KOHA's intranet, the procedure would be: user@host: cd /home/user/koha-2.x/scripts/misc/translator/ user@host: ./tmpl_process3.pl create -r -i /home/user/koha-2.x/intranethtml/intranet-tmpl/default/en/circ/ -s /home/user/translation/circ_es.po In the above example:
'create' indicates that we want to create a new '.po' file. -r indicates that the source is a directory -i indicates the path from where the text string will be extracted -s indicates the path and name of the '.po' file that will be created.
3/10
KOHATranslationTeam
When running the script, there may be some 'warnings' about syntax errors in the original templates. Output will look like this: Warning: Can't determine original templates' charset, defaulting to ISO-8859-1 Removing empty file /home/user/tmp/temp.po xgettext.pl: Warning (negligible): selectbranchprinter.tmpl: line 15: Suggest ESCAPE=HTML for TMPL_VAR in attribute "value": "<!-- TMPL_VAR NAME="value" -->" xgettext.pl: Warning (negligible): selectbranchprinter.tmpl: Further similar negligible warnings will not be reported, use --pedantic for details xgettext.pl: Warning: returns.tmpl: line 17: Strange attribute syntax: /cgibin/koha/moremember.pl?bornum=<!-- TMPL_VAR NAME="bornum" -->", "Member"); return false;" xgettext.pl: Warning: branchtransfers.tmpl: line 20: Probably missing whitespace before or missing quotation mark near: Member", 480, 640); return false;" xgettext.pl: Warning: branchtransfers.tmpl: line 22: Probably missing whitespace before or missing quotation mark near: Member", 480, 640); return false;" xgettext.pl: Warning: branchtransfers.tmpl: line 98: Probably missing whitespace before or missing quotation mark near: Member", 480, 640); return false;" xgettext.pl: Warning: branchtransfers.tmpl: line 128: Probably missing whitespace before or missing quotation mark near: Item", 480, 640); return false;" The create seems to be successful. Despite this warnings, the last line (The create seems to be successful.) indicates that the process has ended successfully and that now we have our brand new 'circ_es.po' file in /home/user/translation/ so now we can use Kbabel to begin the translation process.
4/10
KOHATranslationTeam
The area marked as Original Text is read only and displays the text string to be translated. The area marked as Translated Text is where we will write the translation of the string displayen in the Original Text area. The area marked as File Names displays the path and name of the template files where the text string being translated was extracted from. The area marked as Context displays the previous and next text strings 5/10
KOHATranslationTeam
to the one being translated, to provide some help about the context of the current text string.
Examples
Some tags and markups should not be modified during translation
6/10
KOHATranslationTeam
Whenever the translation implies the use of accented words or special characters, they should be replaced with the corresponding entities, to avoid visualisation problems or errors.
7/10
KOHATranslationTeam
To navigate between text strings and launch some useful commands, there are shorcuts in the toolbar and many keyboard key combinations.
Command
Next text string Previous text string Next not translated text string Previous not translated text string Copy the text string displayed on the Original Text area to the Translated Text area
Keyboard
PgDown PgUp Alt+PgDown Alt+PgUp Ctrl+Espacio
'install' indicates that we want to create a set of templates from a '.po' file. -r indicates that the target is a directory -i indicates the path where the original templates are located (the ones we extracted the text strings from). -s indicates the path and name of the '.po' file that will be used in the process 8/10
KOHATranslationTeam
-o indicates the path where the new set of translated templates will be created
As happened when we launched the script to create the '.po' file, there may be some 'warnings' about syntax errors in the original templates. Output will look like this: Warning: Can't determine original templates' charset, defaulting to ISO-8859-1 Creating /home/jmlongo/documentos/koha/koha-2.1.1/intranet-html/intranettmpl/default/pl/circ//selectbranchprinter.tmpl... tmpl_process3.pl: Warning (negligible): selectbranchprinter.tmpl: line 15: Suggest ESCAPE=HTML for TMPL_VAR in attribute "value": "<!-- TMPL_VAR NAME="value" -->" tmpl_process3.pl: Warning (negligible): selectbranchprinter.tmpl: Further similar negligible warnings will not be reported, use --pedantic for details Creating /home/jmlongo/documentos/koha/koha-2.1.1/intranet-html/intranettmpl/default/pl/circ//returns.tmpl... tmpl_process3.pl: Warning: returns.tmpl: line 17: Strange attribute syntax: /cgibin/koha/moremember.pl?bornum=<!-- TMPL_VAR NAME="bornum" -->", "Member"); return false;" Creating /home/jmlongo/documentos/koha/koha-2.1.1/intranet-html/intranettmpl/default/pl/circ//circulation.tmpl... Creating /home/jmlongo/documentos/koha/koha-2.1.1/intranet-html/intranettmpl/default/pl/circ//branchtransfers.tmpl... tmpl_process3.pl: Warning: branchtransfers.tmpl: line 20: Probably missing whitespace before or missing quotation mark near: Member", 480, 640); return false;" tmpl_process3.pl: Warning: branchtransfers.tmpl: line 22: Probably missing whitespace before or missing quotation mark near: Member", 480, 640); return false;" tmpl_process3.pl: Warning: branchtransfers.tmpl: line 98: Probably missing whitespace before or missing quotation mark near: Member", 480, 640); return false;" tmpl_process3.pl: Warning: branchtransfers.tmpl: line 128: Probably missing whitespace before or missing quotation mark near: Item", 480, 640); return false;" The install seems to be successful. Despite this warnings, the last line (The install seems to be successful.) indicates that the process has ended successfully and that now we have our brand new set of translated templates at /home/user/koha2.x/intranet-html/intranet-tmpl/default/es/circ directory To verify this you can use your favorite text editor to open one of the various templates located in that directory.
9/10
KOHATranslationTeam
10/10