Skip to content

Commit

Permalink
Pass translations from PHP
Browse files Browse the repository at this point in the history
This is a workaround for i18n functions, since they can't be imported into a module
  • Loading branch information
ryelle committed Jan 26, 2024
1 parent f40f856 commit f7d72eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions mu-plugins/blocks/query-filter/render.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ class="wporg-query-filter__modal-action-clear"
/>
<input
type="submit"
data-label-with-count="<?php
/* translators: %s is count of currently selected filters. */
esc_attr_e( 'Apply (%s)', 'wporg' );
?>"
data-label=<?php esc_attr_e( 'Apply', 'wporg' ); ?>
value="<?php echo esc_html( $apply_label ); ?>"
/>
</div> <!-- /.wporg-query-filter__modal-actions -->
Expand Down
5 changes: 2 additions & 3 deletions mu-plugins/blocks/query-filter/src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,9 @@ const { actions } = store( 'wporg/query-filter', {
// Only update the apply button if multiple selections are allowed.
if ( context.hasMultiple ) {
if ( count ) {
/* translators: %s is count of currently selected filters. */
applyButton.value = 'Apply (%s)';
applyButton.value = applyButton.dataset.labelWithCount.replace( '%s', count );
} else {
applyButton.value = 'Apply';
applyButton.value = applyButton.dataset.label;
}
}

Expand Down

0 comments on commit f7d72eb

Please sign in to comment.