Skip to content

Use plugin_lang_get to display repo settings keys, trans bool values #215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Source/Source.API.php
Original file line number Diff line number Diff line change
@@ -10,6 +10,33 @@
* @author John Reese
*/

if (!function_exists('plugin_lang_get_defaulted')) {
/**
* Get a language string for the plugin.
* - If found, return the appropriate string.
* - If not found, no default supplied, return the supplied string as is.
* - If not found, default supplied, return default.
* Automatically prepends plugin_<basename> to the string requested.
* @param string $p_name Language string name.
* @param string $p_default The default value to return.
* @param string $p_basename Plugin basename.
* @return string Language string
*/
function plugin_lang_get_defaulted( $p_name, $p_default = null, $p_basename = null ) {
if( !is_null( $p_basename ) ) {
plugin_push_current( $p_basename );
}
$t_basename = plugin_get_current();
$t_name = 'plugin_' . $t_basename . '_' . $p_name;
$t_string = lang_get_defaulted( $t_name, $p_default );

if( !is_null( $p_basename ) ) {
plugin_pop_current();
}
return $t_string;
}
}

# branch mapping strategies
define( 'SOURCE_EXPLICIT', 1 );
define( 'SOURCE_NEAR', 2 );
6 changes: 4 additions & 2 deletions Source/pages/repo_manage_page.php
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
$f_repo_id = gpc_get_int( 'id' );

$t_repo = SourceRepo::load( $f_repo_id );
$t_vcs = SourceVCS::repo( $t_repo );
$t_type = SourceType($t_repo->type);

$t_mappings = $t_repo->load_mappings();
@@ -74,6 +75,7 @@ function convert_to_key_value( $p_array ) {
return $t_result;
}


layout_page_header( plugin_lang_get( 'title' ) );
layout_page_begin();
?>
@@ -121,8 +123,8 @@ function convert_to_key_value( $p_array ) {
foreach( $t_formatted_array as $t_key => $t_value ) {
?>
<tr>
<td class="category"><?php echo $t_key ?></td>
<td><?php echo $t_value ?></td>
<td class="category"><?php echo plugin_lang_get_defaulted( $t_key, $t_key, $t_vcs->basename ) ?></td>
<td><?php echo is_bool( $t_value ) ? trans_bool( $t_value ) : $t_value ?></td>
</tr>
<?php } ?>
</table>