-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from pedro-mendonca/dev
Add conversion diff highlight
- Loading branch information
Showing
15 changed files
with
425 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* Highlight conversion difference. */ | ||
.translation-text ins { | ||
background-color: #68de7c; | ||
text-decoration: none; | ||
display: inline-block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/** | ||
* Intentionally empty file. | ||
* | ||
* It exists to stop directory listings on poorly configured servers. | ||
* | ||
* @package GP_Convert_PT_AO90 | ||
*/ | ||
|
||
// Silence is golden. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/** | ||
* Intentionally empty file. | ||
* | ||
* It exists to stop directory listings on poorly configured servers. | ||
* | ||
* @package GP_Convert_PT_AO90 | ||
*/ | ||
|
||
// Silence is golden. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
/** | ||
* Intentionally empty file. | ||
* | ||
* It exists to stop directory listings on poorly configured servers. | ||
* | ||
* @package GP_Convert_PT_AO90 | ||
*/ | ||
|
||
// Silence is golden. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
/** | ||
* Template for the preview part of a single translation row in a translation set display | ||
* | ||
* @package GlotPress | ||
* @subpackage Templates | ||
*/ | ||
|
||
$priority_char = array( | ||
'-2' => array( '×', 'transparent', '#ccc' ), | ||
'-1' => array( '↓', 'transparent', 'blue' ), | ||
'0' => array( '', 'transparent', 'white' ), | ||
'1' => array( '↑', 'transparent', 'green' ), | ||
); | ||
|
||
?> | ||
|
||
<tr class="preview <?php gp_translation_row_classes( $translation ); ?>" id="preview-<?php echo esc_attr( $translation->row_id ); ?>" row="<?php echo esc_attr( $translation->row_id ); ?>"> | ||
<?php if ( $can_approve_translation ) : ?> | ||
<th scope="row" class="checkbox"><input type="checkbox" name="selected-row[]"/></th> | ||
<?php elseif ( $can_approve ) : ?> | ||
<th scope="row"></th> | ||
<?php endif; ?> | ||
<?php /* translators: %s: Priority of original */ ?> | ||
<td class="priority" title="<?php echo esc_attr( sprintf( __( 'Priority: %s', 'glotpress' ), gp_array_get( GP::$original->get_static( 'priorities' ), $translation->priority ) ) ); ?>"> | ||
<?php | ||
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | ||
echo $priority_char[ $translation->priority ][0]; | ||
?> | ||
</td> | ||
<td class="original"> | ||
<span class="original-text"><?php echo prepare_original( $translation_singular ); ?></span> | ||
<?php if ( $translation->context ) : ?> | ||
<?php /* translators: %s: Context of original */ ?> | ||
<span class="context bubble" title="<?php echo esc_attr( sprintf( __( 'Context: %s', 'glotpress' ), $translation->context ) ); ?>"><?php echo esc_html( $translation->context ); ?></span> | ||
<?php endif; ?> | ||
</td> | ||
<td class="translation foreign-text"> | ||
<?php | ||
if ( $can_edit ) { | ||
$edit_text = __( 'Double-click to add', 'glotpress' ); | ||
} elseif ( is_user_logged_in() ) { | ||
$edit_text = __( 'You are not allowed to add a translation.', 'glotpress' ); | ||
} else { | ||
/* translators: %s: url */ | ||
$edit_text = sprintf( __( 'You <a href="%s">have to log in</a> to add a translation.', 'glotpress' ), esc_url( wp_login_url( gp_url_current() ) ) ); | ||
} | ||
|
||
$missing_text = "<span class='missing'>$edit_text</span>"; | ||
if ( ! count( array_filter( $translation->translations, 'gp_is_not_null' ) ) ) : | ||
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | ||
echo $missing_text; | ||
elseif ( ! $translation->plural ) : | ||
$singular_translation = esc_translation( $translation->translations[0] ); | ||
// Check if has root. | ||
if ( isset( $translation->root_id ) ) { | ||
$singular_translation = prepare_original( GP_Convert_PT_AO90\Portuguese_AO90::highlight_diff( esc_translation( $translation->root_translation_0 ), esc_translation( $translation->translations[0] ) ) ); | ||
} | ||
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | ||
echo '<span class="translation-text">' . $singular_translation . '</span>'; | ||
else : | ||
?> | ||
<ul> | ||
<?php foreach ( $translation->translations as $key => $current_translation ) : ?> | ||
<li> | ||
<?php | ||
if ( gp_is_empty_string( $current_translation ) ) { | ||
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | ||
echo $missing_text; | ||
} else { | ||
$plural_translation = esc_translation( $current_translation ); | ||
// Check if has root. | ||
if ( isset( $translation->root_id ) ) { | ||
$plural_translation = prepare_original( GP_Convert_PT_AO90\Portuguese_AO90::highlight_diff( esc_translation( $translation->{ 'root_translation_' . $key } ), esc_translation( $current_translation ) ) ); | ||
} | ||
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | ||
echo '<span class="translation-text">' . $plural_translation . '</span>'; | ||
} | ||
?> | ||
</li> | ||
<?php endforeach; ?> | ||
</ul> | ||
<?php endif; ?> | ||
</td> | ||
<td class="actions"> | ||
<a href="#" class="action edit"><?php _e( 'Details', 'glotpress' ); ?></a> | ||
</td> | ||
</tr> |
Oops, something went wrong.