Make WordPress Core

Opened 10 years ago

Last modified 3 months ago

#30049 assigned defect (bug)

wp_load_translations_early does not work without WPLANG defined

Reported by: szepeviktor's profile szepe.viktor Owned by: swissspidy's profile swissspidy
Milestone: 6.7 Priority: normal
Severity: normal Version: 4.0
Component: I18N Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

In the Hungarian WP 4.0 the maintenance text appears in english.

Attachments (1)

30049.diff (556 bytes) - added by soulseekah 6 years ago.
HTTP_ACCEPT_LANGUAGE

Download all attachments as: .zip

Change History (28)

#1 @nacin
10 years ago

This is once WordPress is installed, yes?

#2 @nacin
10 years ago

And installed with the English package but then choosing Hungarian during install, rather than using the Hungarian package.

#3 @szepe.viktor
10 years ago

Yes, the Hungarian packages has $wp_local_package = 'hu_HU';

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


9 years ago

#6 @kidsguide
9 years ago

This is a problem with all the language packages not just Hungarian.

#7 follow-up: @temuag
9 years ago

I've found the solution, see:
https://wordpress.org/support/topic/translation-of-the-maintenance-mode?replies=19

You need to make sure $wp_local_package = 'YOUR LOCAL'; is defined at the end of wp-includes/version.php

The error may come from an upgrade, I had the same issue, and I could fix it this way.

Version 0, edited 9 years ago by temuag (next)

This ticket was mentioned in Slack in #core-i18n by ocean90. View the logs.


8 years ago

#9 in reply to: ↑ 7 ; follow-up: @ocean90
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Replying to temuag:

You need to make sure $wp_local_package = 'YOUR LOCAL'; is defined at the end of wp-includes/version.php

This global variable is defined when you download a localized package from a local site like hu.wordpress.org.

Sadly, there is nothing we can do. We can't access the locale option because wp_maintenance() is loaded before a database connection can be initialized. wp_load_translations_early() is also used for database errors so we can't access the database here too.

Closing as a wontfix, but feel free to reopen if you have a patch ready.

#10 in reply to: ↑ 9 @ocean90
8 years ago

Replying to ocean90:

Sadly, there is nothing we can do.

Maybe $_SERVER['HTTP_ACCEPT_LANGUAGE'] could be an alternative source for setting the locale.

#11 @SergeyBiryukov
7 years ago

#41823 was marked as a duplicate.

#12 @SergeyBiryukov
7 years ago

  • Milestone set to Awaiting Review
  • Resolution wontfix deleted
  • Status changed from closed to reopened

Reopening to look into comment:10.

@soulseekah
6 years ago

HTTP_ACCEPT_LANGUAGE

#13 @soulseekah
6 years ago

Attached a simple HTTP_ACCEPT_LANGUAGE-based locale detection.

Regular expression based on a locale list from here https://stackoverflow.com/questions/3191664/list-of-all-locales-and-their-short-codes#3191729

This is in no way a substitute for the deprecated WPLANG constant. We need to find a way to set the language for those notices without using WPLANG now.

This ticket was mentioned in Slack in #core by ocean90. View the logs.


5 years ago

#15 @swissspidy
5 months ago

  • Keywords needs-patch needs-unit-tests added

Using the heder for this could be interesting. If moved to a separate function, the logic can be testable.

#16 @swissspidy
5 months ago

  • Owner set to swissspidy
  • Status changed from reopened to assigned

#17 @swissspidy
4 months ago

  • Summary changed from wp_load_translations_early does not without WPLANG defined to wp_load_translations_early does not work without WPLANG defined

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


4 months ago
#18

  • Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed

To-do:

  • Decide what to do with values such as de. I think treating those as de_DE makes for the best experience, even though it's not super accurate.

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

#19 @swissspidy
4 months ago

  • Milestone changed from Awaiting Review to 6.7

This ticket was mentioned in PR #6842 on WordPress/wordpress-develop by @ramon fincken.


3 months ago
#20

#21 @ramon fincken
3 months ago

I have read ISO documentation and simplified and somewhat improved the regex a bit ( which was pretty good to be honest ).

Also I allowed for commandline WP-CLI / PHP where this header is not even present ( PHP Warning: Undefined array key "HTTP_ACCEPT_LANGUAGE" )

#22 @swissspidy
3 months ago

@ramon-fincken Mind providing any suggestions on the existing PR instead? It is more sophisticated and includes tests already.

#23 @ramon fincken
3 months ago

I am open for your suggestions if that is what you mean @swissspidy

@swissspidy commented on PR #6842:


3 months ago
#24

There is already great progress over at #6623 with more edge cases covered and proper tests. I suggest focusing on that PR instead.

#25 @swissspidy
3 months ago

No, I mean focusing our effort on the existing PR at https://github.com/WordPress/wordpress-develop/pull/6623 which is nearly complete.

#26 @ramon fincken
3 months ago

Ok what do you need ?

https://github.com/WordPress/wordpress-develop/pull/6623/files#diff-31cd15428a59baa3494149d7ccf047ce80c8d7783d6e889c80d118043548ee1aR2005

empty is not the correct check ( i.e. command-line )

The regex might need some explaining.
Do you have an example where we actually have 3, 4 or 5 for the country ISO wise?

#27 @swissspidy
3 months ago

empty is just fine and works in CLI context where the header is absent. The tests prove that.

Note: See TracTickets for help on using tickets.