Skip to content

Commit

Permalink
Follow-up fix for custom field names translations
Browse files Browse the repository at this point in the history
In the case where we have multiple custom strings localized to the same
string, commit c174d88 would make it
impossible to distinguish them.

While this should not be a major issue in the bug history (as it doesn't
make sense to have more than one fields with a given localized name
within a given project), it is important that in custom field management
as well as project management pages custom fields are uniquely
identified with their "system" name to ensure there is no confusion.

This commit adds a new API function custom_field_get_display_name() that
will append the localized name to the field name, and which is called
from the above-mentioned pages.

Issue #12470
  • Loading branch information
dregad committed Aug 30, 2013
1 parent fa52c99 commit 9b9c2cc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions core/custom_field_api.php
Expand Up @@ -853,6 +853,22 @@ function custom_field_get_field( $p_field_id, $p_field_name ) {
}
}

/**
* Return custom field name including localized name (if available)
*
* @param string $p_name Custom field's name
* @return string CustomFieldName [(LocalizedName)]
* @access public
*/
function custom_field_get_display_name( $p_name ) {
$t_local_name = lang_get_defaulted( $p_name );
if( $t_local_name != $p_name ) {
$p_name .= " ($t_local_name)";
}

return string_display( $p_name );
}

/**
* Get the value of a custom field for the given bug
* @todo return values are unclear... should we error when access is denied
Expand Down
2 changes: 1 addition & 1 deletion manage_custom_field_page.php
Expand Up @@ -69,7 +69,7 @@
?>
<tr <?php echo helper_alternate_class() ?>>
<td>
<a href="manage_custom_field_edit_page.php?field_id=<?php echo $t_field_id ?>"><?php echo string_display( $t_desc['name'] ) ?></a>
<a href="manage_custom_field_edit_page.php?field_id=<?php echo $t_field_id ?>"><?php echo custom_field_get_display_name( $t_desc['name'] ) ?></a>
</td>
<td>
<?php echo count( custom_field_get_project_ids( $t_field_id ) ) ?>
Expand Down
2 changes: 1 addition & 1 deletion manage_proj_edit_page.php
Expand Up @@ -564,7 +564,7 @@
?>
<tr <?php echo helper_alternate_class() ?>>
<td>
<?php echo string_display( lang_get_defaulted( $t_desc['name'] ) ) ?>
<?php echo custom_field_get_display_name( $t_desc['name'] ) ?>
</td>
<td>
<form method="post" action="manage_proj_custom_field_update.php">
Expand Down

0 comments on commit 9b9c2cc

Please sign in to comment.