vue-a11y/vue-announcer

Pass custom function to produce the route change announcement

tcitworld opened this issue ยท 4 comments

Currently it's just concatenating message and complement.

Vue.prototype.$announcer.set(`${msg} ${complement}`, politeness)

For i18n purposes, it would be nice to pass a function when installing the plugin that would allow to define how this works, something like:

(message) => {
  return this.$gettext('%{ message } has been loaded');
}

Hi @tcitworld

You can use the setComplementRoute method to update the route complement when the language changes.

This method is just about changing the complement. I'm talking about totally customizing how the announcement is build.

Imagine a language where the order of the sentence would be like Loaded homepage. It wouldn't be possible with the current concatenation order.

I came here to give this feature request my vote as well. There's often a case where the title of the page includes some brand naming, which can be redundant for route announces. In such case the relevant part of the route could be parsed via this kind of function.

Here is also my feature request, somewhat similar to this. We are needing this feature for being able to properly translate the route change message with I18N setup: #27 (comment)