Skip to content

Namespaces

Shortcuts are stored in YAML files, organized by namespaces. They are part of the /data subdirectory.

Every shortcut belongs to exactly one namespace. Namespaces allow the same keyword to be used for different shortcuts – according to the user's language, location or personal setup. This comes in handy e.g. for multi-country websites like Amazon:

  • a shakespeare shall search Amazon for books from Shakespeare – but Amazon from which country?

Thanks to namespaces, we can have the keyword a both

  • in the US country namespace .us,
  • as also in the Germany namespace .de

Depending on the country in your settings and thus the namespaces you use, the correct shortcut for Amazon will be picked.

But even more: You can also override shortcuts: For instance, while all other users use the keyword g for Google, you might use it for something else – with your user namespace.

Namespaces work well together with Includes, especially for dictionaries.

Namespace types

Namespace type Example namespaces Naming convention Contains Example shortcuts
language de, en 2 chars, by ISO 639-1 shortcuts related to a particular language Merriam-Webster dictionary: mw tree (from en)
country .de, .us dot and 2 chars, by ISO 3166-1 alpha2 shortcuts related to a particular country Deutsche Bahn Fahrplanauskunft: db berlin, hamburg (from .de)
dictionary dcm (dict.com), lge (Linguee) 3 chars, by their abbreviated name shortcuts from a dictionary website German-English: de-en tree, en-de tree, en-<$language> tree (using language variable from settings)
user georgjaehnig a GitHub username (can be overridden with a custom name) custom shortcuts created by a user in their repo Trains from my home station: db> hamburg
planet o the shape of the planet shortcuts unrelated to a language or country Google web search: g berlin

language, country, dictionary and o (planet) are site namespaces. They are curated and here to find. (Pull requests are welcome.)

Dictionary namespaces

Currently, the following dictionary namespaces are defined:

Namespace Dictionary
alm Online Latein Wörterbuch
ard arabdict
bab bab.la
beo BEOLINGUS
crd croDict
dcc dict.cc
dcm Dictionary.com
deo Dans-Esperanto ordbog
dtn Deutsch-Tuerkisch.net
esd SpanishDictionary.com
flx Folkets lexikon
hzn Heinzelnisse
irs Irishionary.com
leo leo.org
lge Linguee
lgs Langenscheidt
mdb MDBG Chinese Dictionary
pka pauker.at
pns PONS dictionary
rvs Reverso
umt uitmuntend
wdk Wadoku
zrg Zargan

Uniqueness in a namespace

In a namespace, there can be only one shortcut with the same keyword and the same number of arguments: So in o, there is only one shortcut g with one argument, the Google web search.

Using namespaces

Basic

The namespaces you use are derived from your settings (settings wheel left of the input field). For instance, having set

  • language: English
  • country: Unites States

your namespaces will be:

  • o (planet namespace)
  • en (English language)
  • .us (USA)

Advanced (with your GitHub account)

Your namespaces are derived from your config.yml. With your personal configuration, you can use more than 3 namespaces. This can be useful when you like to use shortcuts from multiple languages and countries, e.g. dictionaries or public transport while travelling.

Priority of namespaces

The lower a namespace is in the namespaces list, the higher it's precedence. This is similar to Object-oriented programming, when a method needs to be picked from inheriting classes.

So in the example before, shortcuts from .us override those from en, and both those from o.

Per-call namespace, also overrides language or country

Let's say you have configured language=en but this time, you want to search the German Wikipedia. In this case, call

de.w berlin
So for a single call, you can prefix your query with NAMESPACE.. This namespace will then have the highest priority.

If that prefixed namespace happens to be a language or country namespace, it will also override the current language or country.

Example in detail

Settings

Let's assume we use Trovu with these settings:

language: en
country: us
namespaces:
    - o
    - en
    - .us

Query

Now we call this query:

de.w berlin

Here, we add the namespace de. This means that for this very query

  • the de namespace is added to the namespaces list, with the highest priority.
  • Also, since de is a language, the language setting is changed to de.

So this query is now processed as if the settings were:

language: de
country: us
namespaces:
    - o
    - en
    - .us
    - de

Result

Instead of the English Wikipedia (that would have been used with language: en), the German Wikipedia is used, because language is now set to de, and the Wikipedia shortcut's URL is defined as url: https://<$language>.wikipedia.org/....

Had another shortcut w 1 existed in namespace de, then this shortcut would have been called, because we had added these namespaces to the subscribed namespaces, with the highest priority.

Default language and country

Calling the homepage URL without any namespaces will set the default language and country based on navigator.language.