Opened 7 years ago
Closed 7 years ago
#42241 closed defect (bug) (fixed)
MediaElement should use the correct locale string
Reported by: | johnbillion | Owned by: | westonruter |
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | normal | Version: | 4.9 |
Component: | Media | Keywords: | has-patch commit |
Focuses: | javascript | Cc: |
Description
The mejsL10n.language
property is populated by get_bloginfo( 'language' )
. This is incorrect as this data is intended to populate the lang
attribute on the html
element. get_locale()
should be used instead.
See #42071
Attachments (5)
Change History (16)
#2
@
7 years ago
What if the user's language is different from the site's language? Should not the language be determined more dynamically? Should it not be get_user_locale()
when in the admin? If the user has selected language A but the site has language B, then they should get MediaElement.js with language A in the Customizer controls but in the customizer preview it should get language B, right?
#4
@
7 years ago
42241.1.diff uses get_user_locale()
when is_admin()
.
This patch also replaces the locale underscore with a hyphen, so es_MX
gets replaced with es-MX
. However, I don't really see this working as expected. I changed my locale to Mexican Spanish but then the player still had a “Play” tooltip: mejs-language-not-spanish.png.
It seems like ME.js isn't loading the locale.
#5
@
7 years ago
If the translation are not matching the structure described in script-loader.php any changes would be reflected.
@
7 years ago
Add mejsL10n global as inline script before the mediaelement-core
script instead of after the mediaelement
script.
#6
@
7 years ago
@rafa8626 In order for me to see “Reproducir” when I hover over the play button instead of “Play” I needed to do 42241.3.diff. I found that the mejsL10n
global was getting output too late, after mediaelement-and-player.js
already ran, and so the data from that variable was not accounted for.
I'm not sure if what I'm doing for mejsL10n.language
is right.
#7
@
7 years ago
@westonruter I think your approach is right. It's one of those things I didn't consider changing before because of my lack of knowledge in terms of WP processes scripts and variables in that file. My apologies I didn't catch this before.
#8
@
7 years ago
@rafa8626 What is the purpose of the language
passed in to mejsL10n
if we're already passing in all of the strings? Is my handling of the language/country code right or even necessary?
#9
@
7 years ago
@westonruter It is necessary since the player is relying on that value to be passed to set the translation object correctly and perform the translation in the controls
@johnbillion The patch has been submitted in this ticket; please test and let us know if it works for you. Thanks @westonruter