Permalink
Browse files

Further lang_get updates

  • Loading branch information...
1 parent 52c646c commit b97cdba15655c5ebcbb8c26ada86fa5340e0b321 @grangeway grangeway committed Feb 4, 2013
Showing with 106 additions and 1,544 deletions.
  1. +23 −0 core.php
  2. +7 −3 core/classes/MantisError.class.php
  3. +12 −5 core/filter_api.php
  4. +34 −16 core/string_api.php
  5. +0 −1,518 lang/strings_english.txt
  6. +1 −1 login_page.php
  7. +29 −1 my_view_inc.php
View
@@ -254,6 +254,29 @@ function __autoload( $p_class ) {
set_error_handler(array('MantisError', 'error_handler'));
register_shutdown_function(array('MantisError', 'shutdown_error_handler'));
+/* Guess the current locale from the Accept-Language header or fall back to
+ * the default locale defined in config_inc.php. The core gettext text domain
+ * will also be loaded so strings from here on in are translated into the
+ * user's preferred language.
+ *
+ * TODO: also check for a locale override provided by a user cookie?
+ *
+ * TODO: make mention of a user override that is applied later on once a user
+ * identifies themselves by logging in?
+ */
+//use Locale\LocaleManager;
+
+$localeManager = new Locale();
+
+//try {
+// $localeManager->setLocale();
+//} catch (LocaleNotSupportedByUser $e) {
+// $localeManager->setLocale($g_default_locale);
+//}
+
+//$localeManager->addTextDomain('core', LOCALE_PATH);
+textdomain('core');
+
# Include PHP compatibility file
require_api( 'php_api.php' );
@@ -179,7 +179,9 @@ public static function display_errors() {
# We need to ensure compression is off - otherwise the compression headers are output.
- compress_disable();
+ if( function_exists('compress_disable' ) ) {
+ compress_disable();
+ }
# then clean the buffer, leaving output buffering on.
if( $t_oblen > 0 ) {
@@ -191,7 +193,9 @@ public static function display_errors() {
echo '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" >';
echo '<head><title>Error Page</title>';
echo '<style>table.width70 { width: 70%; border: solid 1px #000000; }</style></head><body>';
- echo '<p align="center"><img src="' . helper_mantis_url( 'themes/' . config_get( 'theme' ) . '/images/logo.png' ) . '" /></p>';
+ if( function_exists( 'helper_mantis_url' ) ) {
+ echo '<p align="center"><img src="' . helper_mantis_url( 'themes/' . config_get( 'theme' ) . '/images/logo.png' ) . '" /></p>';
+ }
echo '<hr />';
echo '<div align="center">';
@@ -233,7 +237,7 @@ public static function display_error( $p_error) {
echo '<br /><div><table class="width70" cellspacing="1">';
echo '<tr><td class="form-title">' . $p_error->name . '</td></tr>';
if ( !self::$_fatal ) {
- echo '<tr><td><p class="center" style="color:red">' . nl2br( lang_get_defaulted( $p_error->message ) ) . '</p></td></tr>';
+ echo '<tr><td><p class="center" style="color:red">' . nl2br( _( $p_error->message ) ) . '</p></td></tr>';
} else {
echo '<tr><td><p class="center" style="color:red">' . nl2br( $p_error->message ) . '</p></td></tr>';
}
View
@@ -3079,7 +3079,8 @@ function filter_draw_selection_area2( $p_page_number, $p_for_screen = true, $p_e
if( isset( $t_accessible_custom_fields_names[$i] ) ) {
$t_fields .= '<td class="small-caption"> ';
$t_fields .= '<a href="' . $t_filters_url . 'custom_field_' . $t_accessible_custom_fields_ids[$i] . '[]" id="custom_field_' . $t_accessible_custom_fields_ids[$i] . '_filter"' . $t_dynamic_filter_expander_class . '>';
- $t_fields .= string_display( lang_get_defaulted( $t_accessible_custom_fields_names[$i] ) );
+ /* TODO L10N: translation support for custom field names */
+ $t_fields .= string_display_line( $t_accessible_custom_fields_names[$i] );
$t_fields .= '</a> </td> ';
}
$t_output = '';
@@ -3261,12 +3262,17 @@ function filter_draw_selection_area2( $p_page_number, $p_for_screen = true, $p_e
}
$t_sort = $t_sort_fields[$i];
if( strpos( $t_sort, 'custom_' ) === 0 ) {
- $t_field_name = string_display( lang_get_defaulted( mb_substr( $t_sort, 7 ) ) ); // 7 = length of 'custom_'
+ /* TODO L10N: translation support for custom field names */
+ $t_field_name = string_display( mb_substr( $t_sort, mb_strlen( 'custom_' ) ) );
} else {
$t_field_name = string_get_field_name( $t_sort );
}
- echo $t_field_name . ' ' . lang_get( 'bugnote_order_' . mb_strtolower( $t_dir_fields[$i] ) );
+ if (mb_strtolower($t_dir_fields[$i]) === 'asc') {
+ echo $t_field_name . ' ' . _('Ascending');
+ } else {
+ echo $t_field_name . ' ' . _('Descending');
+ }
echo '<input type="hidden" name="', FILTER_PROPERTY_SORT_FIELD_NAME, '_', $i, '" value="', $t_sort_fields[$i], '" />';
echo '<input type="hidden" name="', FILTER_PROPERTY_SORT_DIRECTION, '_', $i, '" value="', $t_dir_fields[$i], '" />';
}
@@ -4019,7 +4025,8 @@ function print_filter_show_sort() {
for( $i = 0;$i < $t_n_fields;$i++ ) {
if( !in_array( $t_fields[$i], array( 'selection', 'edit', 'attachment' ) ) ) {
if( strpos( $t_fields[$i], 'custom_' ) === 0 ) {
- $t_field_name = string_display( lang_get_defaulted( mb_substr( $t_fields[$i], 7 ) ) ); // 7 = length of 'custom_'
+ /* TODO L10N: translation support for custom field names */
+ $t_field_name = string_display( mb_substr( $t_fields[$i], mb_strlen( 'custom_' ) ) );
} else {
$t_field_name = string_get_field_name( $t_fields[$i] );
}
@@ -4075,7 +4082,7 @@ function print_filter_show_sort() {
}
echo '</select>';
} else {
- echo lang_get_defaulted( 'last_updated' ) . _( 'Descending' );
+ echo _('Last Updated Descending');
echo '<input type="hidden" name="', FILTER_PROPERTY_SORT_FIELD_NAME, '_1" value="last_updated" />';
echo '<input type="hidden" name="', FILTER_PROPERTY_SORT_DIRECTION, '_1" value="DESC" />';
}
View
@@ -825,23 +825,41 @@ function string_normalize( $p_string ) {
* @return string
*/
function string_get_field_name( $p_string ) {
- $t_map = array(
- 'attachment_count' => 'attachments',
- 'category_id' => 'category',
- 'handler_id' => 'assigned_to',
- 'id' => 'email_bug',
- 'last_updated' => 'updated',
- 'project_id' => 'email_project',
- 'reporter_id' => 'reporter',
- 'view_state' => 'view_status',
- 'bugnotes_count' => 'bugnote',
- );
-
- $t_string = $p_string;
- if( isset( $t_map[$p_string] ) ) {
- $t_string = $t_map[$p_string];
+ /* TODO L10N: make sure this switch statement accounts for all possible field names */
+ switch( $p_string ) {
+ case 'attachment_count':
+ $t_translated = _('Attachment(s)');
+ break;
+ case 'category_id':
+ $t_translated = _('Category');
+ break;
+ case 'handler_id':
+ $t_translated = _('Assigned To');
+ break;
+ case 'id':
+ $t_translated = _('Issue ID');
+ break;
+ case 'last_updated':
+ $t_translated = _('Updated');
+ break;
+ case 'project_id':
+ $t_translated = _('Project');
+ break;
+ case 'reporter_id':
+ $t_translated = _('Reporter');
+ break;
+ case 'view_state':
+ $t_translated = _('View Status');
+ break;
+ case bugnotes_count:
+ $t_translated = _('Bug Note(s)');
+ break;
+ default:
+ $t_translated = $p_string;
+ break;
}
- return lang_get_defaulted( $t_string );
+
+ return $t_translated;
}
/**
Oops, something went wrong.

0 comments on commit b97cdba

Please sign in to comment.