Actions

Difference between revisions of "Debugging a translation"

From Joomla! Documentation

(New page: Joomla supports some useful debugging mechanisms that can make it easier to locate untranslated strings and diagnose problems with language translations in installed extensions. ==== Debu...)
 
m (Fixed formatting issues. Added images.)
Line 2: Line 2:
  
 
==== Debug Language ====
 
==== Debug Language ====
[[Image:]]You activate language debugging via the Administration Back-end by going into Global Configuration and clicking on the System tab. Find the Debug Language field, change the value to “Yes” and save your changes.
+
[[Image:global-config-language-debug.png|right]]You activate language debugging via the Administration Back-end by going into Global Configuration and clicking on the System tab. Find the Debug Language field, change the value to “Yes” and save your changes.
  
 
With this option active all translatable strings are shown surrounded with special characters that indicate their status
 
With this option active all translatable strings are shown surrounded with special characters that indicate their status
 
  
 
{| class="prettytable"
 
{| class="prettytable"
Line 33: Line 32:
  
 
==== Debug Plugin ====
 
==== Debug Plugin ====
[[Image:]]This system plugin controls what is displayed when debugging is activated in '''Global Configuration'''. It is enabled by default. You can access the parameters for the plugin from '''Extensions → Plugin Manager'''. Locate the “System - Debug” plugin and click on it. There are three settings of interest to translators.
+
[[Image:debug-plugin.png|right]]This system plugin controls what is displayed when debugging is activated in '''Global Configuration'''. It is enabled by default. You can access the parameters for the plugin from '''Extensions → Plugin Manager'''. Locate the “System - Debug” plugin and click on it. There are three settings of interest to translators.
  
 
* '''Display loaded language files''' (New in Joomla 1.5.4) Determines whether or not to display the language files that have been loaded to generate the page. This has two modes: diagnostic and designer. Diagnostic mode displays the untranslated string and the likely file location whether the '''JText''' call was made. Designer mode displays the strings in a format that can be copy-pasted into a .ini language file (displays the list in ''KEY=String'' format).  
 
* '''Display loaded language files''' (New in Joomla 1.5.4) Determines whether or not to display the language files that have been loaded to generate the page. This has two modes: diagnostic and designer. Diagnostic mode displays the untranslated string and the likely file location whether the '''JText''' call was made. Designer mode displays the strings in a format that can be copy-pasted into a .ini language file (displays the list in ''KEY=String'' format).  
Line 40: Line 39:
  
 
Note that the display of untranslated strings will only display the value passed to the appropriate '''JText''' method. For example, with the following code:  
 
Note that the display of untranslated strings will only display the value passed to the appropriate '''JText''' method. For example, with the following code:  
 
+
<source lang="php">
echo JText::_( 'Reports Import Configuration' );
+
echo JText::_( 'Reports Import Configuration' );
 
+
</source>
 
If untranslated, Designer mode will display this as:  
 
If untranslated, Designer mode will display this as:  
  

Revision as of 06:15, 17 August 2008

Joomla supports some useful debugging mechanisms that can make it easier to locate untranslated strings and diagnose problems with language translations in installed extensions.

Debug Language

Global-config-language-debug.png

You activate language debugging via the Administration Back-end by going into Global Configuration and clicking on the System tab. Find the Debug Language field, change the value to “Yes” and save your changes.

With this option active all translatable strings are shown surrounded with special characters that indicate their status

●Joomla CMS●
(text surrounded by bullets) indicates that a match has been found in the language definition file and the string has been translated.
??Joomla CMS??
(text surrounded by pairs of question marks) indicates that the string is translatable but no match was found in the language definition file.
Joomla CMS
(text with no surrounding characters) indicates that the string is not translatable.

Debug System

Additional language debugging information can be obtained by activating system debugging. This is done by going into Global Configuration and clicking on the System tab. Find the Debug System field, change the value to “Yes” and save your changes.

With this option active all screens have additional debugging information at the end of each page. Currently this includes

  • Profile information. This is the amount of time taken to execute code up to various mark points in the code.
  • Memory usage. The amount of system RAM used.
  • SQL queries executed. All of the SQL queries executed in the process of building the page.
  • Language files loaded. A list of all the language files loaded in the process of building the page, including full path information. This can be useful to check that the expected files have been loaded. The number after each file path is the number of times that the file was referenced.
  • Untranslated strings diagnostic. A list of all the untranslated strings found and the likely file location given where the JText call was made.
  • Untranslated strings designer. A list of all the untranslated strings found but listed in a KEY=Value format so they can be copy-pasted directly into a language definition file (INI).

Debug Plugin

Debug-plugin.png

This system plugin controls what is displayed when debugging is activated in Global Configuration. It is enabled by default. You can access the parameters for the plugin from Extensions → Plugin Manager. Locate the “System - Debug” plugin and click on it. There are three settings of interest to translators.

  • Display loaded language files (New in Joomla 1.5.4) Determines whether or not to display the language files that have been loaded to generate the page. This has two modes: diagnostic and designer. Diagnostic mode displays the untranslated string and the likely file location whether the JText call was made. Designer mode displays the strings in a format that can be copy-pasted into a .ini language file (displays the list in KEY=String format).
  • Display undefined language strings. Determines whether or not to include undefined language strings in the debug information.
  • Strip Key Prefix (New in Joomla 1.5.4) When untranslated strings are displayed in Designer mode, this allows you to strip a prefix from the string to form the key. This is useful if the designer uses a common prefix for their extensions when using JText methods.

Note that the display of untranslated strings will only display the value passed to the appropriate JText method. For example, with the following code:

echo JText::_( 'Reports Import Configuration' );

If untranslated, Designer mode will display this as:

# /administrator/components/com_reports/views/reports/tmpl/default.php
REPORTS IMPORT CONFIGURATION=Reports Import Configuration

If the Strip Key Prefix is set to "Reports", then the display would change slightly to:

# /administrator/components/com_reports/views/reports/tmpl/default.php
REPORTS IMPORT CONFIGURATION=Import Configuration

Note that the path shown is only a best guess based on a call to the PHP debug_backtrace function. Sometimes it is accurate, sometimes it is not and there are also cases where no file could be determined. In those cases you have to use your best judgement.