Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#31319 closed defect (bug) (fixed)

Use first translation iso instead of by key '1'

Reported by: barrykooij's profile barrykooij Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.2 Priority: normal
Severity: normal Version: 4.2
Component: I18N Keywords: has-patch
Focuses: Cc:

Description

The list of available translations on options-general.php uses $translation['iso'][1] which results into a notice when 1 isn't set (which was the case for me). This patch simply gets the first element from the iso array, which 1 appeared to be anyway.

Tested and patch made on trunk. Let me know if you need more information

Attachments (3)

31319.diff (535 bytes) - added by barrykooij 10 years ago.
31319.2.diff (531 bytes) - added by barrykooij 10 years ago.
31319.3.diff (847 bytes) - added by barrykooij 10 years ago.

Download all attachments as: .zip

Change History (21)

@barrykooij
10 years ago

#1 @SergeyBiryukov
10 years ago

  • Milestone changed from Awaiting Review to 4.2

current() would be preferred to array_shift(), see #31259.

#2 @barrykooij
10 years ago

Thanks, updated to current().

@barrykooij
10 years ago

#3 @SergeyBiryukov
10 years ago

There's a second instance in line 899, seems like it should be updated as well.

Was curious which language doesn't have that key. Looking at the API response, it's Hazaragi (apparently a language pack for it was recently created).

@barrykooij
10 years ago

#4 @barrykooij
10 years ago

Attached new file that also replaces line 899.

The following language was missing the key:

(
    [language] => haz
    [version] => 4.1
    [updated] => 2015-02-12 01:05:09
    [english_name] => Hazaragi
    [native_name] => هزاره گی
    [package] => https://downloads.wordpress.org/translation/core/4.1/haz.zip
    [iso] => Array
        (
            [2] => haz
        )

    [strings] => Array
        (
            [continue] => ادامه
        )

)

#5 @SergeyBiryukov
10 years ago

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

In 31447:

Avoid a PHP notice in wp_install_language_form() and wp_dropdown_languages() if the language doesn't have a ISO 639-1 code.

props barrykooij.
fixes #31319.

#6 @SergeyBiryukov
10 years ago

#31329 was marked as a duplicate.

#7 @SergeyBiryukov
10 years ago

  • Keywords has-patch fixed-major added
  • Milestone changed from 4.2 to 4.1.1
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for 4.1.1 consideration.

#8 @dollar_dad
10 years ago

Tested this patch and can confirm that it works

#9 follow-ups: @dd32
10 years ago

  • Milestone changed from 4.1.1 to 4.2
  • Resolution set to fixed
  • Status changed from reopened to closed

Since it's only a PHP Notice, and doesn't block Language selection nor Installation, I don't think this warrants inclusion in a minor release.

I've already bumped several other PHP Notice-only issues out.

If it makes sense to, we could set the API to return $language['iso'][1] = $language['iso'][1] ? $language['iso'][1] : $language['iso'][2] instead.

#10 in reply to: ↑ 9 ; follow-up: @SergeyBiryukov
10 years ago

Replying to dd32:

Since it's only a PHP Notice, and doesn't block Language selection nor Installation

It does for Hazaragi, so would be nice to fix this either way.

Fixing the API to always return a non-empty ISO 639-1 code sounds like an option, but I'm not sure about repercussions for other languages.

#11 in reply to: ↑ 10 ; follow-up: @ocean90
10 years ago

Replying to SergeyBiryukov:

It does for Hazaragi, so would be nice to fix this either way.

Why? The ISO code is only used for the lang attribute. I could install Hazaragi without problems.

We could change the API to return empty values of languages which don't have an ISO 639-1or ISO 639-2 code, but I don't want to print empty values for the lang attribute, so [31447] is the right fix here.

#12 in reply to: ↑ 11 @SergeyBiryukov
10 years ago

  • Keywords fixed-major removed

Replying to ocean90:

Why? The ISO code is only used for the lang attribute. I could install Hazaragi without problems.

Ah yes, you're right.

#13 @SergeyBiryukov
10 years ago

#31347 was marked as a duplicate.

#14 in reply to: ↑ 9 @SergeyBiryukov
10 years ago

Replying to dd32:

Since it's only a PHP Notice, and doesn't block Language selection nor Installation, I don't think this warrants inclusion in a minor release.

I have a feeling we'll get a lot more duplicates like #31329 or #31347 in the upcoming weeks. Could we reconsider?

#15 follow-up: @Mediastuttgart
10 years ago

for me it blocks the language selection an also prevents the submit button from showing up. so i even can't save the generel settings at all.

#16 @danbp
10 years ago

Fresh local install 4.1.1. Same issue here, like @Mediastuttgart, it's a blocker.

#17 in reply to: ↑ 15 @SergeyBiryukov
10 years ago

Replying to Mediastuttgart:

for me it blocks the language selection an also prevents the submit button from showing up. so i even can't save the generel settings at all.

Which browser are you using? Could not reproduce in Firefox or Chrome. The notice is there in the page source, but it's not visible on the screen, and it doesn't block the submit button.

Perhaps your issue is #30802?

#18 in reply to: ↑ 9 @dd32
10 years ago

Replying to dd32:

If it makes sense to, we could set the API to return $language['iso'][1] = $language['iso'][1] ? $language['iso'][1] : $language['iso'][2] instead.

I did this for WP < 4.2 requests.

Note: See TracTickets for help on using tickets.