-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Site editor: last modified time is not translatable #53888
Comments
Looks like humanTimeDiff doesn't set the locale. i can try to fix |
Not sure about this now. The output of So it might be the way, or even when, we're calling these functions that's causing the problems. The locale is set correctly in the source. Though for me in development, the entire block editor is not translated (tried setting ES and DE as my language in both WP and browser), so I probably need to look at that first. I'm away until next week so I can take a closer look then. Thanks! |
Oh wait, we probably need to add further relative translations. See Core: And the rest in Gutenberg: gutenberg/packages/date/src/index.js Line 111 in eed863a
|
I was also able to reproduce this problem.
As a test, I temporarily hard-coded all the formats for a particular site language as follows, and confirmed that the output was as expected. function wp_default_packages_inline_scripts( $scripts ) {
// ...
$scripts->add_inline_script(
'wp-date',
sprintf(
'wp.date.setSettings( %s );',
wp_json_encode(
array(
'l10n' => array(
// ...
'relative' => array(
/* translators: %s: Duration. */
'future' => __( '%s from now' ),
/* translators: %s: Duration. */
'past' => __( '%s ago' ),
's' => '一秒以内',
'ss' => '%d秒',
'm' => '一分',
'mm' => '%d分',
'h' => '一時間',
'hh' => '%d時間',
'd' => '一日',
'dd' => '%d日',
'M' => '一ヶ月',
'MM' => '%dヶ月',
'y' => '一年',
'yy' => '%d年',
),
),
// ...
)
)
),
'after'
);
// ...
}
If the newly required format is not currently needed in the core, should it be added on the Gutenberg side? Another fundamental problem may be that the format string is hard-coded in the first place. |
Thanks for double-checking!! 🙇🏻 Yep, we'll need something on the Gutenberg side. I haven't tested this theory yet, but I'm hoping we could add an updated inline script from the plugin and thereby make another call to
Since 6.3 it is :) So the core patch would augment the existing values. |
I've added something to Gutenberg in #53931 I'll do the core patch on Monday. The slight complication is that it requires translations so it's not a "right now" fix. An alternative might be to just use a formatted date for these fields instead of |
This was originally reported at https://core.trac.wordpress.org/ticket/47373 What's the reason for fixing this first in Gutenberg by patching core, rather than just fixing this in trunk directly? That just creates more friction and confusion. Not to mention that the GB PR won't do anything anyway when the strings aren't existing & translated in core, which would make it quite pointless. |
Oh, I wasn't aware of it. Thanks for sharing.
Gutenberg supports the last two WordPress releases. At the moment, WordPress 6.2 and WordPress 6.3. Even when/if the fix is released as part of WordPress 6.4, Gutenberg still has to support WordPress 6.3. I think it's worth enabling users to see the string in their language faster than 6.4 is available (and before they update). |
Oh, let me unwrap this @swissspidy. My understanding is that because Gutenberg creates new strings, those will be available for translation as soon as the corresponding Gutenberg version is released (16.6, in a few days). Is this correct? |
Yes and no. The strings will be picked up by string extraction and can be translated in the Gutenberg project on translate.wordpress.org, but since you are using the |
Got it. Thanks, Pascal. Prepared a fix at #53995 |
TIL Thanks for the explainer. I wasn't sure, thinking that |
Description
Some strings from global styles revisions are not translatable.
Step-by-step reproduction instructions
Environment info
I tested this on WordPress 6.3, though the string comes from Gutenberg.
The corresponding lines point to the use of
humanTimeDiff
function here and here.The text was updated successfully, but these errors were encountered: