Convert transformation descriptions to gettext.

This commit is contained in:
Michal Čihař
2010-05-24 12:04:20 +02:00
parent 31010806f7
commit e0b32c7aaa
17 changed files with 106 additions and 15 deletions

View File

@@ -2576,6 +2576,18 @@ setfacl -d -m "g:www-data:rwx" tmp
field (i.e. 'text/plain', 'image/jpeg' etc.)</li>
</ol>
<p> Additionally you should also provide additional function to provide
information about the transformation to the user. This function should
have same name as transformation function just with appended
<code>_info</code> suffix. This function accepts no parameters and returns
array with information about the transformation. Currently following keys
can be used:
<p>
<dl>
<dt><code>info</code></dt>
<dd>Long description of the transformation.</dd>
</dl>
<!-- FAQ -->
<h2 id="faq">FAQ - Frequently Asked Questions</h2>

View File

@@ -129,17 +129,4 @@ $strShowStatusThreads_cachedDescr = __('The number of threads in the thread cach
$strShowStatusThreads_connectedDescr = __('The number of currently open connections.');
$strShowStatusThreads_createdDescr = __('The number of threads created to handle connections. If Threads_created is big, you may want to increase the thread_cache_size value. (Normally this doesn\'t give a notable performance improvement if you have a good thread implementation.)');
$strShowStatusThreads_runningDescr = __('The number of threads that are not sleeping.');
$strTransformation_application_octetstream__download = __('Displays a link to download the binary data of the field. You can use the first option to specify the filename, or use the second option as the name of a field which contains the filename. If you use the second option, you need to set the first option to the empty string.');
$strTransformation_application_octetstream__hex = __('Displays hexadecimal representation of data. Optional first parameter specifies how often space will be added (defaults to 2 nibbles).');
$strTransformation_image_jpeg__inline = __('Displays a clickable thumbnail. The options are the maximum width and height in pixels. The original aspect ratio is preserved.');
$strTransformation_image_jpeg__link = __('Displays a link to download this image.');
$strTransformation_image_png__inline = __('See image/jpeg: inline');
$strTransformation_text_plain__dateformat = __('Displays a TIME, TIMESTAMP, DATETIME or numeric unix timestamp field as formatted date. The first option is the offset (in hours) which will be added to the timestamp (Default: 0). Use second option to specify a different date/time format string. Third option determines whether you want to see local date or UTC one (use "local" or "utc" strings) for that. According to that, date format has different value - for "local" see the documentation for PHP\'s strftime() function and for "utc" it is done using gmdate() function.');
$strTransformation_text_plain__external = __('LINUX ONLY: Launches an external application and feeds it the field data via standard input. Returns the standard output of the application. The default is Tidy, to pretty-print HTML code. For security reasons, you have to manually edit the file libraries/transformations/text_plain__external.inc.php and list the tools you want to make available. The first option is then the number of the program you want to use and the second option is the parameters for the program. The third option, if set to 1, will convert the output using htmlspecialchars() (Default 1). The fourth option, if set to 1, will prevent wrapping and ensure that the output appears all on one line (Default 1).');
$strTransformation_text_plain__formatted = __('Displays the contents of the field as-is, without running it through htmlspecialchars(). That is, the field is assumed to contain valid HTML.');
$strTransformation_text_plain__imagelink = __('Displays an image and a link; the field contains the filename. The first option is a URL prefix like "http://www.example.com/". The second and third options are the width and the height in pixels.');
$strTransformation_text_plain__link = __('Displays a link; the field contains the filename. The first option is a URL prefix like "http://www.example.com/". The second option is a title for the link.');
$strTransformation_text_plain__sql = __('Formats text as SQL query with syntax highlighting.');
$strTransformation_text_plain__substr = __('Displays a part of a string. The first option is the number of characters to skip from the beginning of the string (Default 0). The second option is the number of characters to return (Default: until end of string). The third option is the string to append and/or prepend when truncation occurs (Default: "...").');
?>

View File

@@ -12,6 +12,12 @@
* extension. For further information regarding naming conventions see the /Documentation.html file.
*/
function PMA_transformation_[ENTER_FILENAME_HERE]_info() {
return array(
'info' => __('Description of the transformation.'),
);
}
function PMA_transformation_[ENTER_FILENAME_HERE]($buffer, $options = array(), $meta = '') {
// possibly use a global transform and feed it with special options:
// include('./libraries/transformations/global.inc.php');

View File

@@ -5,6 +5,12 @@
* @version $Id$
*/
function PMA_transformation_application_octetstream__download_info() {
return array(
'info' => __('Displays a link to download the binary data of the field. You can use the first option to specify the filename, or use the second option as the name of a field which contains the filename. If you use the second option, you need to set the first option to the empty string.'),
);
}
/**
*
*/

View File

@@ -5,6 +5,12 @@
* @version $Id$
*/
function PMA_transformation_application_octetstream__hex_info() {
return array(
'info' => __('Displays hexadecimal representation of data. Optional first parameter specifies how often space will be added (defaults to 2 nibbles).'),
);
}
/**
*
*/

View File

@@ -5,6 +5,12 @@
* @version $Id$
*/
function PMA_transformation_image_jpeg__inline_info() {
return array(
'info' => __('Displays a clickable thumbnail. The options are the maximum width and height in pixels. The original aspect ratio is preserved.'),
);
}
/**
*
*/

View File

@@ -5,6 +5,12 @@
* @version $Id$
*/
function PMA_transformation_image_jpeg__link_info() {
return array(
'info' => __('Displays a link to download this image.'),
);
}
/**
*
*/

View File

@@ -5,6 +5,12 @@
* @version $Id$
*/
function PMA_transformation_image_png__inline_info() {
return array(
'info' => __('Displays a clickable thumbnail. The options are the maximum width and height in pixels. The original aspect ratio is preserved.'),
);
}
/**
*
*/

View File

@@ -5,6 +5,12 @@
* @version $Id$
*/
function PMA_transformation_text_plain__dateformat_info() {
return array(
'info' => __('Displays a TIME, TIMESTAMP, DATETIME or numeric unix timestamp field as formatted date. The first option is the offset (in hours) which will be added to the timestamp (Default: 0). Use second option to specify a different date/time format string. Third option determines whether you want to see local date or UTC one (use "local" or "utc" strings) for that. According to that, date format has different value - for "local" see the documentation for PHP\'s strftime() function and for "utc" it is done using gmdate() function.'),
);
}
/**
*
*/

View File

@@ -5,6 +5,12 @@
* @version $Id$
*/
function PMA_transformation_text_plain__external_info() {
return array(
'info' => __('LINUX ONLY: Launches an external application and feeds it the field data via standard input. Returns the standard output of the application. The default is Tidy, to pretty-print HTML code. For security reasons, you have to manually edit the file libraries/transformations/text_plain__external.inc.php and list the tools you want to make available. The first option is then the number of the program you want to use and the second option is the parameters for the program. The third option, if set to 1, will convert the output using htmlspecialchars() (Default 1). The fourth option, if set to 1, will prevent wrapping and ensure that the output appears all on one line (Default 1).'),
);
}
/**
*
*/

View File

@@ -5,6 +5,12 @@
* @version $Id$
*/
function PMA_transformation_text_plain__formatted_info() {
return array(
'info' => __('Displays the contents of the field as-is, without running it through htmlspecialchars(). That is, the field is assumed to contain valid HTML.'),
);
}
/**
*
*/

View File

@@ -5,6 +5,12 @@
* @version $Id$
*/
function PMA_transformation_text_plain__imagelink_info() {
return array(
'info' => __('Displays an image and a link; the field contains the filename. The first option is a URL prefix like "http://www.example.com/". The second and third options are the width and the height in pixels.'),
);
}
/**
*
*/

View File

@@ -5,6 +5,12 @@
* @version $Id$
*/
function PMA_transformation_text_plain__link_info() {
return array(
'info' => __('Displays a link; the field contains the filename. The first option is a URL prefix like "http://www.example.com/". The second option is a title for the link.'),
);
}
/**
*
*/

View File

@@ -5,6 +5,12 @@
* @version $Id$
*/
function PMA_transformation_text_plain__longToIpv4_info() {
return array(
'info' => __('Converts an (IPv4) Internet network address into a string in Internet standard dotted format.'),
);
}
/**
* returns IPv4 address
*

View File

@@ -5,6 +5,12 @@
* @version $Id$
*/
function PMA_transformation_text_plain__sql_info() {
return array(
'info' => __('Formats text as SQL query with syntax highlighting.'),
);
}
/**
*
*/

View File

@@ -5,6 +5,12 @@
* @version $Id$
*/
function PMA_transformation_text_plain__substr_info() {
return array(
'info' => __('Displays a part of a string. The first option is the number of characters to skip from the beginning of the string (Default 0). The second option is the number of characters to return (Default: until end of string). The third option is the string to append and/or prepend when truncation occurs (Default: "...").'),
);
}
/**
*
*/

View File

@@ -53,11 +53,19 @@ foreach ($types['mimetype'] as $key => $mimetype) {
$odd_row = true;
foreach ($types['transformation'] as $key => $transform) {
$func = strtolower(str_ireplace('.inc.php', '', $types['transformation_file'][$key]));
$desc = 'strTransformation_' . $func;
require './libraries/transformations/' . $types['transformation_file'][$key];
$funcname = 'PMA_transformation_' . $func . '_info';
$desc = '<i>' . sprintf(__('No description is available for this transformation.<br />Please ask the author what %s does.'), 'PMA_transformation_' . $func . '()') . '</i>';
if (function_exists($funcname)) {
$desc_arr = $funcname();
if (isset($desc_arr['info'])) {
$desc = $desc_arr['info'];
}
}
?>
<tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
<td><?php echo $transform; ?></td>
<td><?php echo (isset($$desc) ? $$desc : '<i>' . sprintf(__('No description is available for this transformation.<br />Please ask the author what %s does.'), 'PMA_transformation_' . $func . '()') . '</i>'); ?></td>
<td><?php echo $desc; ?></td>
</tr>
<?php
$odd_row = !$odd_row;