Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

select with lang="en" ignores language overrides #5995

Open
vjandrea opened this issue Mar 5, 2021 · 11 comments
Open

select with lang="en" ignores language overrides #5995

vjandrea opened this issue Mar 5, 2021 · 11 comments

Comments

@vjandrea
Copy link

vjandrea commented Mar 5, 2021

A message override works only if the lang attribute is not set or if lang is set to any value except "en".
Tested with select2@4.0.13 and jquery@3.2 and confirmed in Chrome and Firefox on Mac and Win10.

$(document).ready(function() {
    $('.message-override').select2(
    {
      language: {
        noResults: () => {
          return 'override works';
        }
      }
    });
});
<select class="message-override">           <!-- works -->
<select class="message-override" lang="fr"> <!-- works -->
<select class="message-override" lang="en"> <!-- does not work -->

JSbin: http://jsbin.com/ludiyeg/edit?html,js,output

P.S. btw the JSbin template proposed in the issue editor is outdated, it should load the latest stable version but it points to an old release candidate instead.

@kevin-brown
Copy link
Member

Because of the way that the language fallback chain works with Select2, if the lang option is set directly on the element then that language file will be set as the highest priority within Select2. This is different from if it's set as a parent attribute, where it is set as the lowest priority in the chain.


Leaving this ticket open since this is not well documented right now.

@vjandrea
Copy link
Author

@kevin-brown I still don't get why setting lang="fr" on the element the js override works, but if lang="en" it doesn't. So English has a higher priority than js override regardless? BTW in the jsbin example you can see that the <html> tag has not a lang attribute set, on purpose, so the lowest priority should not be engaged at all.

@stale
Copy link

stale bot commented Jun 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@kevin-brown
Copy link
Member

Okay there might actually be a bug here specifically for en and I need to look some more into it.

@vjandrea
Copy link
Author

Thanks @kevin-brown, I tried to debug this without success.

@stale
Copy link

stale bot commented Aug 22, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale label Aug 22, 2021
@kevin-brown
Copy link
Member

Weird, I'm not sure why it's marking this as stale but let's reset that.

@stale stale bot removed the status: stale label Aug 22, 2021
@stale
Copy link

stale bot commented Mar 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale label Mar 2, 2022
@jonahgreenthal
Copy link

The project maintainer deliberately chose to leave this open, so it should be left open

@stale stale bot removed the status: stale label Mar 2, 2022
@stale
Copy link

stale bot commented May 1, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale label May 1, 2022
@vjandrea
Copy link
Author

vjandrea commented May 2, 2022 via email

@stale stale bot removed the status: stale label May 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants