Skip to content
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

Fix i18n issues #295

Merged
merged 5 commits into from
Aug 6, 2024
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
37 changes: 19 additions & 18 deletions includes/class-simple-local-avatars.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class Simple_Local_Avatars {
public function __construct() {
$this->add_hooks();

$this->options = (array) get_option( 'simple_local_avatars' );
$this->user_key = 'simple_local_avatar';
$this->rating_key = 'simple_local_avatar_rating';
$this->options = (array) get_option( 'simple_local_avatars' );
$this->user_key = 'simple_local_avatar';
$this->rating_key = 'simple_local_avatar_rating';

if (
! $this->is_avatar_shared() // Are we sharing avatars?
Expand Down Expand Up @@ -432,7 +432,7 @@ public function get_simple_local_avatar_url( $id_or_email, $size ) {
$dest_file_url = '';
if ( false !== strpos( $dest_file, $upload_path['basedir'] ) ) {
$dest_file_url = str_replace( $upload_path['basedir'], $upload_path['baseurl'], $dest_file );
} else if ( is_multisite() && false !== strpos( $dest_file, ABSPATH . 'wp-content/uploads' ) ) {
} elseif ( is_multisite() && false !== strpos( $dest_file, ABSPATH . 'wp-content/uploads' ) ) {
$dest_file_url = str_replace( ABSPATH . 'wp-content/uploads', network_site_url( '/wp-content/uploads' ), $dest_file );
}

Expand Down Expand Up @@ -557,13 +557,13 @@ public function define_avatar_ratings() {
*/
$this->avatar_ratings = array(
/* translators: Content suitability rating: https://en.wikipedia.org/wiki/Motion_Picture_Association_of_America_film_rating_system */
'G' => __( 'G — Suitable for all audiences' ),
'G' => __( 'G — Suitable for all audiences', 'simple-local-avatars' ),
/* translators: Content suitability rating: https://en.wikipedia.org/wiki/Motion_Picture_Association_of_America_film_rating_system */
'PG' => __( 'PG — Possibly offensive, usually for audiences 13 and above' ),
'PG' => __( 'PG — Possibly offensive, usually for audiences 13 and above', 'simple-local-avatars' ),
/* translators: Content suitability rating: https://en.wikipedia.org/wiki/Motion_Picture_Association_of_America_film_rating_system */
'R' => __( 'R — Intended for adult audiences above 17' ),
'R' => __( 'R — Intended for adult audiences above 17', 'simple-local-avatars' ),
/* translators: Content suitability rating: https://en.wikipedia.org/wiki/Motion_Picture_Association_of_America_film_rating_system */
'X' => __( 'X — Even more mature than above' ),
'X' => __( 'X — Even more mature than above', 'simple-local-avatars' ),
);
}

Expand Down Expand Up @@ -702,7 +702,7 @@ public function show_network_settings() {
$this->avatar_settings_field(
array(
'key' => 'only',
'desc' => __( 'Only allow local avatars (still uses Gravatar for default avatars) ', 'simple-local-avatars' ),
'desc' => __( 'Only allow local avatars (still uses Gravatar for default avatars)', 'simple-local-avatars' ),
)
);
?>
Expand Down Expand Up @@ -950,7 +950,7 @@ public function edit_user_profile( $profileuser ) {
if ( ! is_admin() || ! current_user_can( 'upload_files' ) ) {
?>
<p style="display: inline-block; width: 26em;">
<span class="description"><?php esc_html_e( 'Choose an image from your computer:' ); ?></span><br />
<span class="description"><?php esc_html_e( 'Choose an image from your computer:', 'simple-local-avatars' ); ?></span><br />
<input type="file" name="simple-local-avatar" id="simple-local-avatar" class="standard-text" />
</p>
<?php } ?>
Expand All @@ -976,10 +976,10 @@ public function edit_user_profile( $profileuser ) {
</td>
</tr>
<tr class="ratings-row">
<th scope="row"><?php esc_html_e( 'Rating' ); ?></th>
<th scope="row"><?php esc_html_e( 'Rating', 'simple-local-avatars' ); ?></th>
<td colspan="2">
<fieldset id="simple-local-avatar-ratings" <?php disabled( empty( $profileuser->simple_local_avatar ) ); ?>>
<legend class="screen-reader-text"><span><?php esc_html_e( 'Rating' ); ?></span></legend>
<legend class="screen-reader-text"><span><?php esc_html_e( 'Rating', 'simple-local-avatars' ); ?></span></legend>
<?php
if ( empty( $profileuser->simple_local_avatar_rating ) || ! array_key_exists( $profileuser->simple_local_avatar_rating, $this->avatar_ratings ) ) {
$profileuser->simple_local_avatar_rating = 'G';
Expand Down Expand Up @@ -1035,7 +1035,7 @@ public function assign_new_user_avatar( $url_or_media_id, $user_id ) {
*
* @param int $user_id Id of the user who's avatar was updated
*/
do_action( 'simple_local_avatar_updated' , $user_id );
do_action( 'simple_local_avatar_updated', $user_id );
}

/**
Expand Down Expand Up @@ -1064,6 +1064,7 @@ public function edit_user_profile_update( $user_id ) {

$max_upload_size = $this->upload_size_limit( wp_max_upload_size() );
if ( $_FILES['simple-local-avatar']['size'] > $max_upload_size ) {
// translators: %s: Formatted size.
$this->avatar_upload_error = sprintf( __( 'Max allowed avatar size is %s', 'simple-local-avatars' ), size_format( $max_upload_size ) );
add_action( 'user_profile_update_errors', array( $this, 'user_profile_update_errors' ) );
return;
Expand Down Expand Up @@ -1442,9 +1443,9 @@ private function clear_user_avatar_cache( $local_avatars, $user_id, $media_id )
$file_name_data = pathinfo( get_attached_file( $media_id ) );
}

$file_dir_name = $file_name_data['dirname'];
$file_name = $file_name_data['filename'];
$file_ext = $file_name_data['extension'];
$file_dir_name = $file_name_data['dirname'];
$file_name = $file_name_data['filename'];
$file_ext = $file_name_data['extension'];
foreach ( $local_avatars as $local_avatars_key => $local_avatar_value ) {
if ( ! in_array( $local_avatars_key, [ 'media_id', 'full' ], true ) ) {
$file_size_path = sprintf( '%1$s/%2$s-%3$sx%3$s.%4$s', $file_dir_name, $file_name, $local_avatars_key, $file_ext );
Expand Down Expand Up @@ -1477,8 +1478,8 @@ public function add_avatar_default_field( $defaults ) {
<input type="hidden" name="simple-local-avatar-file-id" id="simple-local-avatar-file-id" value="<?php echo ! empty( $default_avatar_file_id ) ? esc_attr( $default_avatar_file_id ) : ''; ?>"/>
<input type="hidden" name="simple-local-avatar-file-url" id="simple-local-avatar-file-url" value="<?php echo ! empty( $default_avatar_file_url ) ? esc_url( $default_avatar_file_url ) : ''; ?>"/>
<?php wp_nonce_field( 'simple_local_avatar_default', 'simple-local-avatar-file-wpnonce' ); ?>
<input type="button" name="simple-local-avatar" id="simple-local-avatar-default" class="button-secondary" value="<?php esc_attr_e( 'Choose Default Avatar', 'simple-local-avatar' ); ?>"/>
<p class="description" style="margin-left: 23px;"><?php esc_html_e( 'Note that this avatar needs to be publicly available or a broken image will be shown.', 'simple-local-avatar' ); ?></p>
<input type="button" name="simple-local-avatar" id="simple-local-avatar-default" class="button-secondary" value="<?php esc_attr_e( 'Choose Default Avatar', 'simple-local-avatars' ); ?>"/>
<p class="description" style="margin-left: 23px;"><?php esc_html_e( 'Note that this avatar needs to be publicly available or a broken image will be shown.', 'simple-local-avatars' ); ?></p>
<?php
$defaults['simple_local_avatar'] = ob_get_clean();

Expand Down
Loading