Skip to content

Commit

Permalink
Replace strings with more user-friendly wordings.
Browse files Browse the repository at this point in the history
  • Loading branch information
dd32 committed Feb 14, 2023
1 parent 249e50d commit ecf180d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 21 deletions.
8 changes: 4 additions & 4 deletions class-two-factor-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,8 @@ public static function login_html( $user, $login_nonce, $redirect_to, $error_msg
echo esc_html(
sprintf(
// translators: %s: Two-factor method name.
__( 'Or, use your backup method: %s →', 'two-factor' ),
$backup_provider->get_label()
__( 'Or, continue with %s →', 'two-factor' ),
$backup_provider->get_singular_label()
)
);
?>
Expand All @@ -727,7 +727,7 @@ public static function login_html( $user, $login_nonce, $redirect_to, $error_msg
<div class="backup-methods-wrap">
<p class="backup-methods">
<a href="javascript:;" onclick="document.querySelector('ul.backup-methods').style.display = 'block';">
<?php esc_html_e( 'Or, use a backup method', 'two-factor' ); ?>
<?php esc_html_e( 'Or, continue with', 'two-factor' ); ?>
</a>
</p>
<ul class="backup-methods">
Expand All @@ -746,7 +746,7 @@ public static function login_html( $user, $login_nonce, $redirect_to, $error_msg
?>
<li>
<a href="<?php echo esc_url( $login_url ); ?>">
<?php echo esc_html( $backup_provider->get_label() ); ?>
<?php echo esc_html( $backup_provider->get_singular_label() ); ?>
</a>
</li>
<?php endforeach; ?>
Expand Down
31 changes: 21 additions & 10 deletions providers/class-two-factor-backup-codes.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,16 @@ public function admin_notices() {
* @since 0.1-dev
*/
public function get_label() {
return _x( 'Backup Verification Codes (Single Use)', 'Provider Label', 'two-factor' );
return _x( 'Backup Codes', 'Provider Label', 'two-factor' );
}

/**
* Returns the singular name of the provider.
*
* @since 0.8
*/
public function get_singular_label() {
return _x( 'Backup Code', 'Provider Label', 'two-factor' );
}

/**
Expand Down Expand Up @@ -162,24 +171,26 @@ public function user_options( $user ) {
$count = self::codes_remaining_for_user( $user );
?>
<p id="two-factor-backup-codes">
<button type="button" class="button button-two-factor-backup-codes-generate button-secondary hide-if-no-js">
<?php esc_html_e( 'Generate Verification Codes', 'two-factor' ); ?>
</button>
<span class="two-factor-backup-codes-count">
<p class="two-factor-backup-codes-count">
<?php
echo esc_html(
sprintf(
/* translators: %s: count */
_n( '%s unused code remaining.', '%s unused codes remaining.', $count, 'two-factor' ),
/* translators: %s: count */
_n( '%s unused code remaining, each backup code can only be used once.', '%s unused codes remaining, each backup code can only be used once.', $count, 'two-factor' ),
$count
)
);
?>
</span>
</p>
<p>
<button type="button" class="button button-two-factor-backup-codes-generate button-secondary hide-if-no-js">
<?php esc_html_e( 'Generate new verification codes', 'two-factor' ); ?>
</button>
</p>
</p>
<div class="two-factor-backup-codes-wrapper" style="display:none;">
<ol class="two-factor-backup-codes-unused-codes"></ol>
<p class="description"><?php esc_html_e( 'Write these down! Once you navigate away from this page, you will not be able to view these codes again.', 'two-factor' ); ?></p>
<p class="description"><?php esc_html_e( 'Write these down! Once you navigate away from this page, you will not be able to view these codes again.', 'two-factor' ); ?></p>
<p>
<a class="button button-two-factor-backup-codes-download button-secondary hide-if-no-js" href="javascript:void(0);" id="two-factor-backup-codes-download-link" download="two-factor-backup-codes.txt"><?php esc_html_e( 'Download Codes', 'two-factor' ); ?></a>
<p>
Expand Down Expand Up @@ -288,7 +299,7 @@ public function rest_generate_codes( $request ) {

$i18n = array(
/* translators: %s: count */
'count' => esc_html( sprintf( _n( '%s unused code remaining.', '%s unused codes remaining.', $count, 'two-factor' ), $count ) ),
'count' => esc_html( sprintf( _n( '%s unused code remaining, each backup code can only be used once.', '%s unused codes remaining, each backup code can only be used once.', $count, 'two-factor' ), $count ) ),
);

if ( $request->get_param( 'enable_provider' ) && ! Two_Factor_Core::enable_provider_for_user( $user_id, 'Two_Factor_Backup_Codes' ) ) {
Expand Down
11 changes: 11 additions & 0 deletions providers/class-two-factor-provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ protected function __construct() {
*/
abstract public function get_label();

/**
* Returns the singular name of the provider.
*
* @since 0.8.0
*
* @return string
*/
public function get_singular_label() {
return $this->get_label();
}

/**
* Prints the name of the provider.
*
Expand Down
13 changes: 6 additions & 7 deletions providers/class-two-factor-totp.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function register_rest_routes() {
* Returns the name of the provider.
*/
public function get_label() {
return _x( 'Time Based One-Time Password (TOTP)', 'Provider Label', 'two-factor' );
return _x( 'Authenticator app', 'Provider Label', 'two-factor' );
}

/**
Expand Down Expand Up @@ -354,16 +354,15 @@ public function user_two_factor_options( $user ) {

<?php else : ?>
<p class="success">
<?php esc_html_e( 'Secret key is configured and registered. It is not possible to view it again for security reasons.', 'two-factor' ); ?>
<?php esc_html_e( 'An Authenticator app is currently configured. You will need to re-scan the QR code on all devices if reset.', 'two-factor' ); ?>
</p>
<p>
<a class="button reset-totp-key" href="#"><?php esc_html_e( 'Reset Key', 'two-factor' ); ?></a>
<em class="description">
<?php esc_html_e( 'You will have to re-scan the QR code on all devices as the previous codes will stop working.', 'two-factor' ); ?>
</em>
<button type="button" class="button button-secondary reset-totp-key hide-if-no-js">
<?php esc_html_e( 'Reset Authenticator app', 'two-factor' ); ?>
</button>
<script>
( function( $ ) {
$( 'a.reset-totp-key' ).click( function( e ) {
$( '.button.reset-totp-key' ).click( function( e ) {
e.preventDefault();

wp.apiRequest( {
Expand Down

0 comments on commit ecf180d

Please sign in to comment.