Make WordPress Core

Opened 6 weeks ago

Closed 4 weeks ago

Last modified 4 weeks ago

#65005 closed defect (bug) (fixed)

Next/Previous for datepicker needs context

Reported by: timse201's profile timse201 Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 7.0 Priority: normal
Severity: normal Version:
Component: I18N Keywords: has-patch commit dev-reviewed i18n-change
Focuses: Cc:

Description

Many locales can't use one word for different contexts. E.g. we Germans like to see "Nächster"/"Vorheriger" instead of "Weiter" which means more or less move forward or continue and is only used when it must be.

https://build.trac.wordpress.org/browser/branches/7.0/wp-includes/script-loader.php?marks=2023#L2017

Attachments (1)

65005.diff (1.7 KB) - added by mdhori15 5 weeks ago.
The 7.0 branch still uses ( 'Next' ) and ( 'Previous' ) in wp_localize_jquery_ui_datepicker(). Attaching a patch to backport the _x() fix from trunk with proper context strings so translators can pick the correct grammatical form.

Download all attachments as: .zip

Change History (14)

#1 @anupkankale
6 weeks ago

I'm working on a patch for this. Will submit a PR shortly.

#65005

#2 @timse201
6 weeks ago

@anupkankale thank you

This ticket was mentioned in PR #11412 on WordPress/wordpress-develop by @anupkankale.


6 weeks ago
#3

  • Keywords has-patch added

Trac ticket: https://core.trac.wordpress.org/ticket/65005

## Description
Adds context for translators to disambiguate 'Next' and 'Previous' in the datepicker navigation.

This helps translators in languages like German where different words are used depending on context (e.g., "Nächster"/"Vorheriger" instead of "Weiter").

## Changes

  • Changed __( 'Next' ) to _x( 'Next', 'datepicker: navigate to next month' ) in src/wp-includes/script-loader.php
  • Changed __( 'Previous' ) to _x( 'Previous', 'datepicker: navigate to previous month' ) in src/wp-includes/script-loader.php

## Testing

  1. The strings will now appear with context in translate.wordpress.org
  2. No functional changes to the datepicker behavior

#4 @anupkankale
6 weeks ago

I've created a pull request for this:

https://github.com/WordPress/wordpress-develop/pull/11412

Changed:

  • __( 'Next' ) to _x( 'Next', 'datepicker: navigate to next month' )
  • __( 'Previous' ) to _x( 'Previous', 'datepicker: navigate to previous month' )

in src/wp-includes/script-loader.php (lines 2023-2024).

#5 @SergeyBiryukov
6 weeks ago

  • Milestone changed from Awaiting Review to 7.0

#6 @SergeyBiryukov
6 weeks ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 62188:

I18N: Add context for Next/Previous strings in the jQuery UI datepicker.

Follow-up to [37849].

Props timse201, anupkankale.
Fixes #65005.

#7 @SergeyBiryukov
6 weeks ago

  • Keywords commit dev-feedback added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for 7.0 consideration.

#8 @audrasjb
6 weeks ago

  • Keywords dev-reviewed i18n-change added; dev-feedback removed

The change looks good to me. Adding dev-reviewed and i18n-change workflow keywords.

This ticket was mentioned in Slack in #core-test by r1k0. View the logs.


6 weeks ago

#10 @gaisma22
6 weeks ago

Patch Testing Report

Patch Tested: https://github.com/WordPress/wordpress-develop/pull/11412

Environment

  • WordPress: 7.0-beta6-62085-src
  • PHP: 8.3.30
  • Server: nginx/1.29.7
  • Database: MySQL 8.4.8
  • Browser: Brave
  • OS: Ubuntu 24.04
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None
  • Plugins: None

Steps Taken

  1. Applied PR #11412.
  2. Opened Posts > Add New and clicked the publish date field to open the datepicker.
  3. Clicked Next and Previous buttons to navigate between months. Both buttons worked correctly.

✅ Patch is solving the problem

Expected Result

The datepicker Next and Previous buttons should function correctly
after the i18n context strings are added.

Additional Notes

  1. This is a pure i18n change. No visual difference is expected. The strings Next and Previous now use _x() with translator context instead of __(), helping translators in languages where context determines the correct word.
  2. Datepicker navigation confirmed working on WordPress 7.0-beta6.

Screenshots

https://i.ibb.co/jvXTKGkr/datepicker-working.png

https://i.ibb.co/ks6xV3ZW/after-datepicker.png

@mdhori15
5 weeks ago

The 7.0 branch still uses ( 'Next' ) and ( 'Previous' ) in wp_localize_jquery_ui_datepicker(). Attaching a patch to backport the _x() fix from trunk with proper context strings so translators can pick the correct grammatical form.

#11 @audrasjb
5 weeks ago

Hello and thank you @mdhori15 but this is already fixed in trunk by this changeset: [62188].
Now we only need to backport this changeset to branch 7.0 and this doesn't require a new patch :)

#12 @jorbin
4 weeks ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 62242:

I18N: Add context for Next/Previous strings in the jQuery UI datepicker.

Follow-up to [37849].

Reviewed by jorbin, audrasjb.
Merges [62188] to the 7.0 branch.

Props timse201, anupkankale, sergeyBiryukov.
Fixes #65005.

This ticket was mentioned in Slack in #polyglots by jorbin. View the logs.


4 weeks ago

Note: See TracTickets for help on using tickets.