Labs/Ubiquity/Parser 2 API Conversion Tutorial

From MozillaWiki
< Labs‎ | Ubiquity
Revision as of 09:04, 22 June 2009 by Mitcho (talk | contribs)
Jump to navigation Jump to search

Intro

Ubiquity 0.5 introduces an updated command API, reflecting the changes in the parser as well as the new ability to localize commands. This tutorial will walk you through some of the key changes you will need to make. If you are interested in writing a new Ubiquity command from scratch, please refer to the updated Command Authoring Tutorial.

A note on (backwards) compatibility

Converting your command

names

Specifying semantic roles

Using semantic roles in preview and execute

Making your command localizable

Ubiquity doesn't yet support the localization of commands which are not bundled with Ubiquity itself. However, the localization of community commands is being planned, so making your command localizable now will future-proof your command and will later open your command up to a much wider target audience.

In addition to the Parser 2 API changes listed above, the main change to be made is to wrap any localizable strings in your preview and execute methods with the function _(). This _() command (familiar to anyone with prior experience with Gettext) handles the localization by finding the appropriate matching localized string on preview or execution.



More tips on making strings localizable can be found in Making Commands Localizable.

References