#42510 closed defect (bug) (fixed)
Error messages rendered by JS are not translated
Reported by: | munyagu | Owned by: | westonruter |
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | major | Version: | 4.9 |
Component: | I18N | Keywords: | has-patch dev-reviewed |
Focuses: | Cc: |
Description
This messages do not appear in GlotPress.
'There is %d error which must be fixed before you can save.'
https://github.com/WordPress/WordPress/blob/e8229a25d5f4c620ef5f021abe70224cc6c550de/wp-includes/widgets/class-wp-widget-custom-html.php#L180
This one is translated but not reflected online.
'Your PHP code changes were rolled back due to an error on line %1$s of file %2$s. Please fix and try saving again.'
https://github.com/WordPress/WordPress/blob/e8229a25d5f4c620ef5f021abe70224cc6c550de/wp-admin/includes/file.php#L303
see:https://wordpress.slack.com/archives/C02RP50LK/p1510283499000069
Attachments (11)
Change History (36)
This ticket was mentioned in Slack in #polyglots by munyagu. View the logs.
7 years ago
#3
@
7 years ago
There is %d error which must be fixed before you can save.
I can see this string in GlotPress, under the "4.9.x - Development" project.
It's in ja.po but not in admin-ja.po.
This one is translated but not reflected online.
Make sure you're using updated translation files on your site
I tried again and it was translated.
Sorry.
#4
in reply to:
↑ 2
@
7 years ago
Hi, I updated to recent nightly build 4.9-RC2-42149 and also the translations, but the issue is the same.
#5
@
7 years ago
It's in ja.po but not in admin-ja.po.
That's correct. Strings are in either ja.po OR admin-ja.po, not in both. https://github.com/WordPress/WordPress/blob/e8229a25d5f4c620ef5f021abe70224cc6c550de/wp-includes/widgets/class-wp-widget-custom-html.php#L180 is not in wp-admin, thus the string won't be in admin-ja.po anyway.
#6
@
7 years ago
Does it mean the messages for the administrative screens, which are arguments to the translation functions, are not translated on the administration screen?
Is it correct?
These messages are included in decompiled my ja.mo.
These messages means "There is %d error which must be fixed before you can save." and "Unable to save due to %s invalid setting.".
#7
@
7 years ago
Same issue with german - I even downloaded the full translation package and replaced the one I got on my HD, I've seen the translations are in the .po - but no. I wonder if it has to do with the usage of _n_noop
in script-loader.php.
#9
@
7 years ago
I am getting the same issue.
I can confirm that the string is in the .po file and I tried to compile to .mo file from the po file (so the mo file must have the string), but still getting same.
Tested on WP 4.9-RC2, VCCW, with Japanese translation.
This ticket was mentioned in Slack in #core by presskopp. View the logs.
7 years ago
#11
@
7 years ago
@swissspidy
I did not recognize, not only admin-ja.mo
but also ja.mo
is load in administration screen.
I noticed that customizer preview would not be displayed unless aja.mo
was loaded with @Presskopp comment.
#12
follow-up:
↓ 15
@
7 years ago
Im getting the same issue, too.
In addition of _n_noop
, _n
seems to be unable to reflect translation: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-customize-manager.php?marks=2702#L2702
#13
@
7 years ago
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 4.9
- Severity changed from normal to major
As mentioned in the DocBlock, _n_noop()
does not translate strings. So the use of wp_array_slice_assoc()
and _n_noop()
doesn't really work.
For a possible workaround without string changes see 42510.patch (incomplete). Not perfect, ideally it should be two separate strings until we have a proper i18n API in JS.
#15
in reply to:
↑ 12
;
follow-up:
↓ 16
@
7 years ago
Replying to odysseygate:
Im getting the same issue, too.
In addition of_n_noop
,_n
seems to be unable to reflect translation: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-customize-manager.php?marks=2702#L2702
Maybe it's because that same string appears with _n_noop()
in script-loader.php
:
Whereas it appears with _n()
in class-wp-customize-manager.php
:
Maybe the _n_noop()
is clobbering the _n()
. I confess I don't understand the mechanics of i18n very well.
#16
in reply to:
↑ 15
@
7 years ago
Replying to westonruter:
Maybe the _n_noop() is clobbering the _n(). I confess I don't understand the mechanics of i18n very well.
The issue is the _n_noop()
doesn't perform translations - it's literally an array passthrough for use later by translate_nooped_plural()
- it's not an issue of being clobbered.
https://developer.wordpress.org/reference/functions/_n_noop/ has an example of that usage (plus the source of the function there)
So instead, it should pass through a translated 'singular' and a translated 'plural' string to JS (be that two _n()
's using 1 & 2 as the count as in 42510.patch, or literally __()
twice), both of those will be incorrect in some languages, but as @ocean90 said, until we have a JS translation API such as what Gutenberg is using, we have no other way to do it properly.
Maybe it's because that same string appears with _n_noop() in script-loader.php:
Just to note, if it's not clear - all of those _n_noop()
calls there will need changing, as they're all not currently translated strings.
#17
@
7 years ago
- Keywords has-patch dev-feedback added; needs-patch removed
42510.2.diff fixes the the remaining JS-targeted usages of _n_noop()
.
In all I count 4 instances:
- Error message when adding invalid HTML to the Custom HTML widget.
- Error message in Customizer's global notification area when there is an invalid setting.
- Error message in Customizer's Additional CSS when there is a syntax error.
- Error message in theme/plugin editor when there are linting errors.
@dd32 @ocean90 Would either of you dev-reviewed and commit to trunk and the 4.9 branch so translators can get to work prior to a planned RC3 in ~12 hours?
#18
@
7 years ago
42510.2.diff looks good to me!
#19
@
7 years ago
- Keywords dev-reviewed added; dev-feedback removed
42510.2.diff Looks good to me, tested that a translated string appears in the custom CSS error message, would like someone who can read a non-en locale verify it too though :)
Tested using Japanese, and the original string in question appears translated (Tested using trunk) - https://cloudup.com/cxMxRfcHWZS
This ticket was mentioned in Slack in #core-i18n by westonruter. View the logs.
7 years ago
#22
@
7 years ago
I can see the strings in the image (https://cloudup.com/cxMxRfcHWZS) are translated properly. Looks good to commit.
I can see this string in GlotPress, under the "4.9.x - Development" project.
Make sure you're using updated translation files on your site