Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The locales form build, validation and submission callbacks to account for languages with hyphenated langcodes.
Steps to reproduce
With a site configured with multiple languages, including custom languages with hyphenated lang codes.
- Go to /admin/config/services/bazaarvoice
- Configure locales
- Save form
- Review configured locales
- Observe languages with hyphenated
Proposed resolution
TBD
Remaining tasks
TBD
User interface changes
TBD
API changes
TBD
Data model changes
TBD
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#11 | bazaarvoice-localecode-3124596-8.patch | 5.67 KB | santoine |
Comments
Comment #2
jasonawantNotes
Comment #3
santoine CreditAttribution: santoine commentedPatch for https://www.drupal.org/project/bazaarvoice/issues/3124596#comment-13536531
Comment #4
santoine CreditAttribution: santoine at Nerdery for Nestle Purina PetCare - United States commentedSave locales hyphenated langcodes correctly.
Comment #5
santoine CreditAttribution: santoine at Nerdery for Nestle Purina PetCare - United States commentedSave locales hyphenated langcodes correctly.
Comment #6
jasonawantpatch does not apply when using composer; only include relevant changes and I'll try again.
Comment #7
santoine CreditAttribution: santoine at Nerdery for Nestle Purina PetCare - United States commentedSave locales hyphenated langcodes correctly. This change should allow user's to apply patch via composer.
Comment #8
jasonawantThanks for the patch santoine!
I took some time to review methods getBazaarvoiceLocaleCode(), and its related methods: isValidLocaleCode, getLocaleCode, findDefaultLocale and defaultLocaleCodes().
I've also reviewed the BV documentation on locales and supported locales.
BV supported locales. are not 1:1 with the list of the modules default codes seen here, e.g af_NA (first default code) is not a supported BV code.
I don't think it makes much sense to manage default locales in code as BV may change that. I created #3143372: Replace default codes with help text and link to supported BV locales.
Regarding the original reported issue and getBazaarvoiceLocaleCode(), I don't see a need to transform or validate the langcode at all in order to fetch the mapped locale code, do you?
I think the
$locale_code = $langcode;
confuses things greatly b/c while it makes sense to validate BV locale codes for its expected language_COUNTRY format. However, when getBazaarvoiceLocaleCode validates it's validating the langcode, not BV locale code.Currently,
Recommended change to preserve the possibility of this return FALSE as previously observed.
However, now looking at this, getBazaarvoiceLocaleCode() and getLocaleCode() can be the same and thus getBazaarvoiceLocaleCode() and remove getLocaleCode(); it was only being used by getBazaarvoiceLocaleCode().
Comment #9
santoine CreditAttribution: santoine at Nerdery for Nestle Purina PetCare - United States commentedThis patch significantly cleans up the bazaarvoice service removing unnecessary code.
Comment #10
jasonawantLooks good!
Looks like setLocaleCodes() is used in AdminSettingsForm::submitForm(), so we'll need to keep this method, which sets the mapped langcode to locale to bazaarvoice.locales.
Comment #11
santoine CreditAttribution: santoine at Nerdery for Nestle Purina PetCare - United States commentedAdd code style changes. Now compatible with other patches.
Comment #12
kamkejj CreditAttribution: kamkejj at Nerdery for Nestle Purina PetCare - United States commentedLooks like this issue included this patch. Check what's in patch #11 and the code changes are applied on the dev branch.
I think this can be closed.
Comment #13
kamkejj CreditAttribution: kamkejj at Nerdery for Nestle Purina PetCare - United States commented