Skip to content

Commit

Permalink
Localize OpenSearch engines names and descriptions
Browse files Browse the repository at this point in the history
The $g_search_title prefix is inserted into the language strings to
produce the final text used both to advertise and register the search
engine in the user's browser.

Issue #11964
  • Loading branch information
dregad committed Aug 9, 2016
1 parent 81862b1 commit 7702000
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
12 changes: 6 additions & 6 deletions browser_search_plugin.php
Expand Up @@ -34,20 +34,20 @@
require_api( 'config_api.php' );
require_api( 'gpc_api.php' );

$f_type = gpc_get_string( 'type', 'text' );
$f_type = strtolower( gpc_get_string( 'type', 'text' ) );

$t_path = config_get_global( 'path' );
$t_title = config_get_global( 'search_title' );
$t_icon = $t_path . config_get_global( 'favicon_image' );
$t_searchform = $t_path . 'view_all_bug_page.php';

if( strtolower( $f_type ) == 'id' ) {
$t_shortname = $t_title . ' IssueId';
$t_description = $t_title .' Issue Id Search';
# Localized ShortName and Description elements
$t_shortname = sprintf( lang_get( "opensearch_{$f_type}_short" ), $t_title );
$t_description = sprintf( lang_get( "opensearch_{$f_type}_description" ), $t_title );

if( $f_type == 'id' ) {
$t_url = $t_path . 'view.php?id={searchTerms}';
} else {
$t_shortname = $t_title . ' Search';
$t_description = $t_title . ' Text Search';
$t_url = $t_path . 'view_all_set.php?type=1&temporary=y&handler_id=[all]&search={searchTerms}';
}

Expand Down
10 changes: 5 additions & 5 deletions config_defaults_inc.php
Expand Up @@ -851,11 +851,11 @@
$g_window_title = 'MantisBT';

/**
* OpenSearch ShortName prefix.
* This is used to describe Browser Search entries, and must be 8 chars or
* less to be compliant with the OpenSearch specification (since we append up to
* 8 chars to differentiate text- and id-based searches, and the maximum length
* of the ShortName element is 16 chars).
* OpenSearch engine title prefix.
* This is used to describe Browser Search entries, and must be short enough
* so that when inserted into the 'opensearch_XXX_short' language string, the
* resulting text is 16 characters or less, to be compliant with the limit for
* the ShortName element as defined in the OpenSearch specification.
* @link http://www.opensearch.org/Specifications/OpenSearch/1.1
* @see $g_window_title
* @global string $g_search_title
Expand Down
9 changes: 3 additions & 6 deletions core/html_api.php
Expand Up @@ -206,14 +206,11 @@ function html_page_top1( $p_page_title = null ) {

# Advertise the availability of the browser search plug-ins.
$t_title = config_get_global( 'search_title' );
$t_searches = array(
'text' => $t_title . ': ' . 'Text Search',
'id' => $t_title . ': ' . 'Issue Id Search',
);
foreach( $t_searches as $t_type => $t_label ) {
$t_searches = array( 'text', 'id' );
foreach( $t_searches as $t_type ) {
echo "\t",
'<link rel="search" type="application/opensearchdescription+xml" ',
'title="' . $t_label . '" ',
'title="' . sprintf( lang_get( "opensearch_{$t_type}_description" ), $t_title ) . '" ',
'href="' . string_sanitize_url( 'browser_search_plugin.php?type=' . $t_type, true ) .
'", />',
"\n";
Expand Down
12 changes: 6 additions & 6 deletions docbook/Admin_Guide/en-US/config/display.xml
Expand Up @@ -16,14 +16,14 @@
<varlistentry>
<term>$g_search_title</term>
<listitem>
<para>This is used as prefix for Browser Search entries,
and must be 8 chars or less to be compliant with the
<para>This is used as prefix to describe Browser Search entries,
and must be short enough so that when inserted into the
'opensearch_XXX_short' language string, the resulting text
is 16 characters or less, to be compliant with the limit for
the ShortName element as defined in the
<ulink url="http://www.opensearch.org/Specifications/OpenSearch/1.1">
OpenSearch specification
</ulink>
(since we append up to 8 chars to differentiate text- and
id-based searches, and the maximum length of the
<emphasis>ShortName </emphasis> element is 16 chars).
</ulink>.
</para>
<para>Defaults to the value of $g_window_title.</para>
</listitem>
Expand Down
6 changes: 6 additions & 0 deletions lang/strings_english.txt
Expand Up @@ -180,6 +180,12 @@ $s_create_new_project_link = 'Create New Project';

$s_login_link = 'Login';

# Browser Search - %s is the Search Engine title (@see $g_search_title)
$s_opensearch_id_short = '%s Id';
$s_opensearch_id_description = '%s: search by Issue Id';
$s_opensearch_text_short = '%s Text';
$s_opensearch_text_description = '%s: full-text search';

# comboboxes default to this to instruct user to explicitly select an entry.
$s_select_option = '(select)';

Expand Down

0 comments on commit 7702000

Please sign in to comment.