Topic on Extension talk:GuidedTour/Archive2

Navigate to the next step using a custom function and i18n

6
Rillke (talkcontribs)
Mattflaschen (talkcontribs)

You can use action: 'next' as you are, if you don't need to do anything else on the same button. If you do, you can use mw.libs.guiders.next(); in an onclick, and action: 'okay'.

As for i18n, GuidedTour supports it for extension-developed tours (you're leveraging that support in your workaround). I don't currently plan to implement custom support for i18n tours on-wiki. We looked at it when the extension started, but didn't see a clean way to do it. I think the best approach is to finish Gadgets 2.0 (yes, I know it's been delayed), rather than every extension doing this its own way.

The workaround you're using is okay. However, just for completeness you can alternatively use a separate i18n mechanism and pass regular strings instead of messages. See Extension:GuidedTour/Write an on-wiki_tour#Test tour code walkthrough; note description can be used instead of descriptionmsg, etc (same for the other ones ending in msg).

Thanks for using GuidedTour; let me know how I can help further.

This post was posted by Mattflaschen, but signed as Superm401.

Rillke (talkcontribs)

Tried that but the following was sent to the server despite using &uselang=de in the address bar:

action	parse
format	json
page	Help:Nominate for deletion/gt/msg/welcome/description

Without the user's language choice is submitted as well to the API, the message is returned in English. This is not really an option as Commons offers its contents to anonymous users in their chosen language by using the uselang parameter.

commons:Help:Nominate for deletion/gt/msg/welcome/description, Special:Permalink/106939382.

I guess you look for the response of the function passed to onShow and evaluate if it is a Promise, and if it is the tour waits for the operation to succeed? Could I use this for completely custom i18n logic or do you intend making changes to that code part?

Image annotator, for example has put all its translation into a template. This would be the easiest option for translators currently (and it would not require admin actions for each changed translation). I am also using this for the watchlist notice and this also gives me a nice overview over translation work that was already done. I'll care for escaping and everything like that.

Thank you for the comprehensive reply.

Mattflaschen (talkcontribs)

If I understand right, you were experimenting with gt.getPageAsDescription. You raise a good point. It should preserve the user's language when calling the API, and it does not. I've noted bugzilla:55664 for this.

The way this API-based parsing/onShow works is not as clean as it should be. It is using synchronous requests. However, I plan to change that (bugzilla:44925). When I fix bug 55664, that will give you a way to do proper translation of on-wiki parsing.

I may not keep onShow intact, but I will consider if I can provide a way to make tour definitions fully asynchronous.

This post was posted by Mattflaschen, but signed as Superm401.

Rillke (talkcontribs)

Oops, I should have read your full message before going to Gerrit, sorry; yes, I was experimenting with gt.getPageAsDescription -- should have mentioned that but thought it was what you suggested this with Extension:GuidedTour/Write an on-wiki_tour#Test tour code walkthrough?

I didn't expect you using synchronous AJAX 😕 -- the promise-approach would be nice, I think. onShow is still useful, even after fixing bugzilla:44925, for example for playing sound. Btw, do you have some best-practices for playing audio files inside guided tour?

Additionally, I do believe GT would be more popular if there would be a creation wizard for a tour, including selecting elements where guiders will be attached to, ...

Finally it is worth mentioning that right/left (position) are automatically flipped for RTL languages, if it isn't already. Otherwise this could lead to confusion for native speakers or RTL-languages.

Mattflaschen (talkcontribs)

I haven't tested your patch yet, but it looks solid. Yes, I did suggest gt.getPageAsDescription as one of the possibilities (note how different steps demo different approaches; I've just explained that a little better).

I don't have an approach for playing sound. I would be very cautious about that, particularly if it starts automatically. You could easily end up annoying the user.

I agree that a creation wizard would be nice (bugzilla:44597), but it is not a priority currently.

I've documented the RTL-flipping. Let me know if anything is still unclear.

This post was posted by Mattflaschen, but signed as Superm401.

Reply to "Navigate to the next step using a custom function and i18n"