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

Translatability fixes #1858

Merged
merged 36 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
798d0c5
Translation and minor code-quality improvements for archive.php
benlk Apr 23, 2020
232e781
add translators: note to homepage error
benlk Apr 23, 2020
acd81e6
add translators: note to image library loading error
benlk Apr 23, 2020
b5a4317
Translation improvements in byline classes
benlk Apr 23, 2020
94770e4
Add translator: notes to inc/header-footer.php
benlk Apr 23, 2020
efc042c
Apply many code standards to inc/header-footer.php
benlk Apr 23, 2020
abff8ae
inc/pagination.php translation notes and code standards
benlk Apr 23, 2020
3ac9d4a
Translators notes for inc/post-metaboxes.php
benlk Apr 23, 2020
5438bcf
Translators notes for inc/post-tags.php
benlk Apr 23, 2020
bb81168
Translators notes and escaping within inc/related-content.php
benlk Apr 23, 2020
4bb820c
Translators notes for inc/update.php
benlk Apr 23, 2020
819b82c
Translators notes for the Largo About widget
benlk Apr 23, 2020
afbf9c7
Translatability improvements in inc/widgets/largo-follow.php
benlk Apr 23, 2020
8f72cfb
Translator notes in inc/widgets/largo-recent-posts.php
benlk Apr 23, 2020
4c5f0c3
Translator notes in inc/widgets/largo-taxonomy-list.php
benlk Apr 23, 2020
e0a9e0e
translator notes and minor array formatting in options.php
benlk Apr 23, 2020
88d4be0
translators note in partials/author-bio-description.php
benlk Apr 23, 2020
9ad62c2
translators note in partials/author-bio-social-links.php
benlk Apr 23, 2020
e056e4c
translators note in partials/content-not-found.php
benlk Apr 23, 2020
36409a1
translators note in partials/footer-boilerplate.php
benlk Apr 23, 2020
1d3200f
translators note in search.php
benlk Apr 23, 2020
84c1c65
update lang/largo.pot
benlk Apr 23, 2020
54e43cf
Fix translation function being fed twitter handle variable in inc/wid…
benlk Apr 24, 2020
9cee382
replace optionsframework placeholder textdomain with largo
benlk Apr 24, 2020
9fa3784
replace argo-links textdomain with largo
benlk Apr 24, 2020
12637f4
Remove a database lookup from a translation function in the Largo Rec…
benlk Apr 24, 2020
87a7817
Remove cf-tax-landing text domain
benlk Apr 24, 2020
0814135
Fix term name being passed to translation function
benlk Apr 24, 2020
033ce93
Prevent site name being passed to translation function
benlk Apr 24, 2020
90e0a37
A lot more revisions to translations functions, mainly adding text do…
benlk Apr 24, 2020
841a290
Allow the Largo Donate widget to have an empty title
benlk Apr 24, 2020
378c33d
Stop piping variables into translation functions
benlk Apr 24, 2020
dad93a9
remove more variables in translation strings
benlk Apr 24, 2020
25b3fec
Bump changelog for https:/INN/largo/pull/1858
benlk Apr 24, 2020
4363211
Remove function output from message translation
benlk Apr 28, 2020
2adf3d4
Remove argnum$ from translated sprintf format strings that only had o…
benlk Apr 28, 2020
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
62 changes: 43 additions & 19 deletions archive.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @since 0.1
* @filter largo_partial_by_post_type
*/

get_header();
$queried_object = get_queried_object();
?>
Expand All @@ -15,7 +16,7 @@
<?php
if ( have_posts() || largo_have_featured_posts() ) {

// queue up the first post so we know what type of archive page we're dealing with
// queue up the first post so we know what type of archive page we're dealing with.
the_post();

/*
Expand All @@ -28,69 +29,90 @@
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
$description = tag_description();
$rss_link = get_tag_feed_link( get_queried_object_id() );
$rss_link = get_tag_feed_link( get_queried_object_id() );
} elseif ( is_tax() ) {
$title = single_term_title( '', false );
$description = term_description();

// rss links for custom taxonomies are a little tricky
// rss links for custom taxonomies are a little tricky.
$term_id = intval( $queried_object->term_id );
$tax = $queried_object->taxonomy;
$rss_link = get_term_feed_link( $term_id, $tax );
} elseif ( is_date() ) {
$description = __( 'Select a different month:', 'largo' );
if ( is_month() ) {
$title = sprintf( __( 'Monthly Archives: <span>%s</span>', 'largo' ), get_the_date( 'F Y' ) );
// translators: this is the PHP date format string for the month and year. Passed to get_the_date(). https://www.php.net/manual/en/datetime.formats.date.php .
$date_format = __( 'F Y', 'largo' );
// translators: %s is the month and year.
$title = sprintf( __( 'Monthly Archives: <span>%s</span>', 'largo' ), get_the_date( $date_format ) );
} elseif ( is_year() ) {
$title = sprintf( __( 'Yearly Archives: <span>%s</span>', 'largo' ), get_the_date( 'Y' ) );
// translators: this is the PHP date format string for the year. Passed to get_the_date(). https://www.php.net/manual/en/datetime.formats.date.php .
$date_format = __( 'Y', 'largo' );
// translators: %s is the year.
$title = sprintf( __( 'Yearly Archives: <span>%s</span>', 'largo' ), get_the_date( $date_format ) );
} else {
$title = _e( 'Blog Archives', 'largo' );
$title = esc_html_e( 'Blog Archives', 'largo' );
}
} elseif ( is_post_type_archive() ) {
} elseif ( is_post_type_archive() ) {
$post_type = $wp_query->query_vars['post_type'];
/**
* Make the title of the post_type archive filterable
*
* @param string $title The title of the archive page
* @since 0.5.4
*/
$title = apply_filters(
'largo_archive_' . $post_type . '_title',
__( post_type_archive_title( '', false ), 'largo' )
post_type_archive_title( '', false )
);
/**
* Make the feed url of the post_type archive filterable
*
* @param string $title The title of the archive page
* @since 0.5.5
*/
$rss_link = apply_filters(
'largo_archive_' . $post_type . '_feed',
site_url('/feed/?post_type=' . urlencode($post_type))
site_url( '/feed/?post_type=' . rawurlencode( $post_type ) )
);
}
?>

<header class="archive-background clearfix">
<?php
if ( isset( $rss_link ) ) {
printf( '<a class="rss-link rss-subscribe-link" href="%1$s">%2$s <i class="icon-rss"></i></a>', $rss_link, __( 'Subscribe', 'largo' ) );
printf(
'<a class="rss-link rss-subscribe-link" href="%1$s">%2$s <i class="icon-rss"></i></a>',
esc_attr( $rss_link ),
esc_html_x( 'Subscribe', 'rss link', 'largo' )
);
}

$post_id = largo_get_term_meta_post( $queried_object->taxonomy, $queried_object->term_id );
largo_hero($post_id);
if ( is_object( $queried_object ) ) {
largo_hero( largo_get_term_meta_post( $queried_object->taxonomy, $queried_object->term_id ) );
}

if ( isset( $title ) ) {
echo '<h1 class="page-title">' . $title . '</h1>';
echo '<h1 class="page-title">' . esc_html( $title ) . '</h1>';
}

if ( isset( $description ) ) {
echo '<div class="archive-description">' . $description . '</div>';
echo '<div class="archive-description">' . wp_kses_post( $description ) . '</div>';
}

if ( is_date() ) {
?>
<nav class="archive-dropdown">
<select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'><option value=""><?php _e('Select Month', 'largo'); ?></option>
<?php wp_get_archives( array('type' => 'monthly', 'format' => 'option' ) ); ?>
<select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
<option value=""><?php esc_html_e( 'Select Month', 'largo' ); ?></option>
<?php
wp_get_archives(
array(
'type' => 'monthly',
'format' => 'option',
)
);
?>
</select>
</nav>
<?php
Expand All @@ -104,16 +126,18 @@
<div class="stories span8" role="main" id="content">
<?php do_action( 'largo_archive_before_stories' ); ?>
<?php
// and finally wind the posts back so we can go through the loop as usual
// Having previously pulled the first post to get information about the taxonomy,
// we now wind the posts back so we can go through the loop as usual.
rewind_posts();
$counter = 1;
while ( have_posts() ) : the_post();
while ( have_posts() ) {
the_post();
$post_type = get_post_type();
$partial = largo_get_partial_by_post_type( 'archive', $post_type, 'archive' );
get_template_part( 'partials/content', $partial );
do_action( 'largo_loop_after_post_x', $counter, $context = 'archive' );
$counter++;
endwhile;
}

largo_content_nav( 'nav-below' );
?>
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Particular thanks go to outside contributor [@seanchayes](https:/sea

### Fixes and minor improvements

- Improved translatability by consolidating Largo to a single text domain, `largo`, and by removing variables from translation functions where possible. [Pull request #1858](https:/INN/largo/pull/1858) for [issue #1592](https:/INN/largo/issues/1592).
- Fixed an issue where the CSS Variables theme option was not working due to improperly escaped regex's in `inc/custom-less-variables.php`. We fixed those expressions and also changed the `put_contents` and `get_contents` functions in the class to be static functions rather than protected. [Pull request #1772](https:/INN/largo/pull/1772) for [issue #1771](https:/INN/largo/issues/1771).
- Removed conflicting duplicate HTML IDs by changing the element ID `header-social` to the class `header-social`, and updating CSS styles to reflect the new selector. [Pull request #1826](https:/INN/largo/pull/1826) for [issue #1781](https:/INN/largo/issues/1781), by [@seanchayes](https:/seanchayes).
- Correct the use of [`validate_file()`](https://developer.wordpress.org/reference/functions/validate_file/), to allow Largo to be used on Windows servers. [Pull request #1850](https:/INN/largo/pull/1850) for [issue #1849](https:/INN/largo/issues/1849).
Expand Down
2 changes: 1 addition & 1 deletion comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<?php if ( have_comments() ) : ?>
<h2 id="comments-title">
<?php
printf( _n( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number() ),
printf( _n( 'One thought on &ldquo;%2$s&rdquo;', '%1$s thoughts on &ldquo;%2$s&rdquo;', get_comments_number(), 'largo' ),
number_format_i18n( get_comments_number() ), '<span>' . get_the_title() . '</span>' );
?>
</h2>
Expand Down
17 changes: 10 additions & 7 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,16 @@ function largo_php_warning() {
$minver = "5.3.0";
$curver = phpversion();

if( current_user_can('update_themes') && version_compare( $curver, $minver, "<" ) ) :
$warning = "Largo requires <b>PHP $minver</b>. You're running <b>$curver</b>. Please upgrade your version of php.";
echo "<div class='update-nag'>";
_e( $warning, 'largo' );
echo "</div>";
endif;

if ( current_user_can('update_themes') && version_compare( $curver, $minver, "<" ) ) {
echo "<div class='update-nag'>";
printf(
// translators: %1$s and %2$s are PHP version numbers.
esc_html__( 'Largo requires <b>PHP %1$s</b>. Your server runs <b>$curver</b>. Please upgrade your version of php.', 'largo'),
$minver,
$curver
);
echo "</div>";
}
}
add_action( 'admin_notices', 'largo_php_warning' );

Expand Down
3 changes: 2 additions & 1 deletion homepages/homepage-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
} else {
wp_die(
sprintf(
// translators: %1$s is the local filename and its path.
esc_html__( 'The WP_Filesystem class could not be found by %1$s', 'largo' ),
__FILE__
),
Expand Down Expand Up @@ -112,7 +113,7 @@ public function registerSidebars() {
register_sidebar( array(
'name' => trim($sb[1]),
'id' => largo_make_slug( trim($sb[1]) ),
'description' => (isset( $sb[3] ) ) ? trim($sb[3]) : __('Auto-generated by current homepage template'),
'description' => (isset( $sb[3] ) ) ? trim($sb[3]) : __( 'Auto-generated by current homepage template', 'largo' ),
'before_widget' => '<aside id="%1$s" class="%2$s clearfix">',
'after_widget' => "</aside>",
'before_title' => '<h3 class="widgettitle">',
Expand Down
2 changes: 1 addition & 1 deletion homepages/homepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ function largo_home_series_stories_data() {

$series_stories = array();

$uncategorized_term = get_term_by('name', __('Uncategorized'), 'category');
$uncategorized_term = get_term_by('name', __('Uncategorized', 'largo'), 'category');
$series_terms = wp_get_post_terms($big_story->ID, 'series');
$category_terms = wp_list_filter(
wp_get_post_terms($big_story->ID, 'category'),
Expand Down
39 changes: 28 additions & 11 deletions homepages/zones/zones.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,34 @@ function homepage_series_stories_list() {

ob_start();
if ( !empty( $feature ) ) {
?>
<h5 class="top-tag"><a class="post-category-link" href="<?php echo get_term_link( $feature ); ?>">
<?php echo __( "More in", "largo" ) . " " . esc_html( $feature->name ) ?></a></h5>
<?php foreach ( $series_posts as $series_post ) {
$shown_ids[] = $series_post->ID; ?>
<h4 class="related-story"><a href="<?php echo esc_url( get_permalink( $series_post->ID ) ); ?>">
<?php echo get_the_title( $series_post->ID ); ?></a></h4>
<?php } ?>
<p class="more"><a href="<?php echo get_term_link( $feature ); ?>">
<?php _e( 'Complete Coverage', 'largo' ); ?></a></p>
<?php
?>
<h5 class="top-tag"><a class="post-category-link" href="<?php echo get_term_link( $feature ); ?>">
<?php
printf(
// translators: %1$s is the name of a term.
__( 'More in %1$s', 'largo' ),
esc_html( $feature->name )
);
?>
</a></h5>
<?php
foreach ( $series_posts as $series_post ) {
$shown_ids[] = $series_post->ID;
?>
<h4 class="related-story"><a href="<?php echo esc_url( get_permalink( $series_post->ID ) ); ?>">
<?php
echo get_the_title( $series_post->ID );
?>
</a></h4>
<?php
}
?>
<p class="more">
<a href="<?php echo get_term_link( $feature ); ?>">
<?php esc_html_e( 'Complete Coverage', 'largo' ); ?>
</a>
</p>
<?php
}
wp_reset_postdata();
$ret = ob_get_contents();
Expand Down
1 change: 1 addition & 0 deletions inc/avatars/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ function largo_save_avatar_field($user_id) {
} else {
wp_die(
sprintf(
// translators: %1$s is the current file's filename and path.
esc_html__( 'wp-admin/includes/image.php could not be loaded by %1$s', 'largo' ),
__FILE__
)
Expand Down
10 changes: 9 additions & 1 deletion inc/byline_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ function generate_byline() {
$authors = $out[0];
} else {
$cap_error_message = sprintf(
// translators: %1$s is a post ID.
esc_html__( 'post %1$s should have at least one co-author, but has none!', 'largo' ),
$this->post_id
);
Expand Down Expand Up @@ -297,7 +298,14 @@ function generate_byline() {
function author_link() {
$author_name = ( ! empty($this->author->display_name) ) ? $this->author->display_name : $this->author->user_nicename ;

$output = '<a class="url fn n" href="' . get_author_posts_url( $this->author->ID, $this->author->user_nicename ) . '" title="' . esc_attr( sprintf( __( 'Read All Posts By %s', 'largo' ), $author_name ) ) . '" rel="author">' . esc_html( $author_name ) . '</a>';
$output = sprintf(
'<a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a>',
get_author_posts_url( $this->author->ID, $this->author->user_nicename ),
// translators: %s is the author name, which is often but not always a human person.
esc_attr( sprintf( __( 'Read All Posts By %s', 'largo' ), $author_name ) ),
esc_html( $author_name )
);

echo $output;
}

Expand Down
8 changes: 6 additions & 2 deletions inc/featured-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,13 +462,17 @@ function largo_featured_image_metabox_callback( $post, $metabox ) {
global $post;

$has_featured_media = largo_has_featured_media( $post->ID );
$language = ( ! empty( $has_featured_media ) ) ? 'Edit' : 'Set';

$checked = 'false' == get_post_meta( $post->ID, 'featured-image-display', true ) ? 'checked="checked"' : "";
echo wp_nonce_field( basename( __FILE__ ), 'featured_image_display_nonce' );

echo '<a href="#" class="set-featured-media">' . get_the_post_thumbnail() . '</a>';
echo '<a href="#" id="set-featured-media-button" class="button set-featured-media add_media" data-editor="content" title="' . __( $language . ' Featured Media', 'largo' ) . '"></span> ' . __( $language . ' Featured Media', 'largo' ) . '</a> <span class="spinner" style="display: none;"></span>';

if ( empty( $has_featured_media ) ) {
echo '<a href="#" id="set-featured-media-button" class="button set-featured-media add_media" data-editor="content" title="' . __( 'Set Featured Media', 'largo' ) . '"></span> ' . __( 'Set Featured Media', 'largo' ) . '</a> <span class="spinner" style="display: none;"></span>';
} else {
echo '<a href="#" id="set-featured-media-button" class="button set-featured-media add_media" data-editor="content" title="' . __( 'Edit Featured Media', 'largo' ) . '"></span> ' . __( 'Edit Featured Media', 'largo' ) . '</a> <span class="spinner" style="display: none;"></span>';
}

echo '<p><label class="selectit"><input type="checkbox" value="true" name="featured-image-display"' . $checked .'> ' . __( 'Hide on Single Post display', 'largo' ) . '</label></p>';
}
Expand Down
Loading