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

Add ability to localize the aria labels #886

Closed
wants to merge 5 commits into from
Closed

Add ability to localize the aria labels #886

wants to merge 5 commits into from

Conversation

jonnitto
Copy link

Unfortunately, all aria labels are hardcoded in English. This PR allows setting the label for page dots and the previous/next buttons.

@jonnitto jonnitto changed the title ✨ Add ability to localize the aria labels Add ability to localize the aria labels Jan 15, 2019
@desandro
Copy link
Member

Add a 👍 reaction to this issue if you would like to see this feature added. Do not add +1 comments — They will be deleted.

Thank you for this PR! This is a nice addition. I'd like see others interest before I decide to add this feature.

@jonnitto
Copy link
Author

Are there any releases planned? This feature is critical to us, as we need to cover accessibility.

@desandro
Copy link
Member

desandro commented Jan 23, 2019

In the meantime, you can add this behavior by adding this duck-punch code before you initialize Flickity

Flickity.defaults.pageDotAriaLabel = 'Page dot %n';
Flickity.defaults.previousAriaLabel = 'Previous';
Flickity.defaults.nextAriaLabel = 'Next';

var addDots = Flickity.PageDots.prototype.addDots;
Flickity.PageDots.prototype.addDots = function() {
  addDots.apply( this, arguments );

  var ariaLabel = this.parent.options.pageDotAriaLabel;
  this.dots.forEach( function( dot, i ) {
    var label = ariaLabel.replace( '%n', i + 1 );
    dot.setAttribute( 'aria-label', label );
  });
};

var _createButton = Flickity.PrevNextButton.prototype._create;
Flickity.PrevNextButton.prototype._create = function() {
  _createButton.apply( this, arguments );
  var optionName = this.isPrevious ? 'previous' : 'next';
  var label = this.parent.options[ optionName + 'AriaLabel' ];
  this.element.setAttribute( 'aria-label', label );
};

You can then set pageDotAriaLabel, previousAriaLabel, and nextAriaLabel option.

@jonnitto
Copy link
Author

Thank you for your example! ❤️ I've adjusted my code with your variable names and changed also the code a bit, to have it the same way as in your example.

@jonnitto
Copy link
Author

Any progress on this?

@vasanthangel4
Copy link

Hi @desandro : when we enabling the voiceover and accessibility carousel scrolling not working with Three-finger triple tap. Safari browser in ios device. android application is working fine. please let us know if you have solution. i have applied accessibility improvement PR, but it is not helping. please let me know if any vanila js fix for this issue.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants