Referencing Languages

Referencing some document in a particular language or the current document in another language is very easily achieved with Qgoda.

Since the asset.lingua variable is just a taxonomy, referencing a particular document in a certain language is just a matter of adding the language to the filter set you are using.

That means that language links are just a special case of Listen und Links. Read there for the full picture. This page just outlines the general idea.

Listings and Links for the Current Language ("l-methods")

All methods of the Qgoda plug-in that take a set of filters as an argument have a corresponding version with the letter "l" prepended to the name that automatically adds a filter for the current language.

Beispiel:

Creating a listing of posts for the tag "JavaScript" looks like this for a single-language site:

[% FOREACH post IN q.list('tags', ['contains', 'JavaScript']) %]
<a href="[% post.permalink %]">[% post.title | html %]</a>
[% END %]

For a multi-language site you would add one more filter:

[% FOREACH post IN q.list('lingua' = asset.lingua
                          'tags', ['contains', 'JavaScript']) %]
<a href="[% post.permalink %]">[% post.title | html %]</a>
[% END %]

And since this is such a common task, you can just use the method q.llist (think "language list") instead that adds that filter automatically:

[% FOREACH post IN q.llist('tags', ['contains', 'JavaScript']) %]
<a href="[% post.permalink %]">[% post.title | html %]</a>
[% END %]

So in the end, a multi-language site requires just a single letter more of template code.

Sprachumschalter

Another common tasks is to create a list of all language variants of a particular document. That can be achieved like this:

<ul>
[% FOREACH lingua IN config.linguas %]
  <li><a href="[% q.link(name=asset.name lingua=lingua) %]">[% lingua %]</a>
[% END %]
</ul>

This is using two filters. The first one is restricting the hits to those documents that have the same name property. The second one lingua=lingua further restricts to the language from the loop variable. Note that lingua=lingua is equivalent to 'lingua'=lingua; the left lingua is the name of the asset variable of the "other" document, the right one is the lopp variable.

Diese Website verwendet Cookies und ähnliche Technologien, um gewisse Funktionalität zu ermöglichen, die Benutzbarkeit zu erhöhen und Inhalt entsprechend ihren Interessen zu liefern. Über die technisch notwendigen Cookies hinaus können abhängig von ihrem Zweck Analyse- und Marketing-Cookies zum Einsatz kommen. Sie können ihre Zustimmung zu den vorher erwähnten Cookies erklären, indem sie auf "Zustimmen und weiter" klicken. Hier können sie Detaileinstellungen vornehmen oder ihre Zustimmung - auch teilweise - mit Wirkung für die Zukunft zurücknehmen. Für weitere Informationen lesen sie bitte unsere Datenschutzerklärung.