lang_links

An article by Gaspard Bucher

Display a link for each languages in the site.

  1. action
  2. ajax
  3. API
  4. classes
  5. common attributes
  6. conditions
  7. context
  8. dates
  9. display
  10. forms
  11. i18n
    1. lang_links
    2. load
    3. trans
    4. wrong_lang
  12. meta
  13. SQLiss
  14. urls

Display a link for each languages in the site.

  • join string to join the links
  • wrap tag to wrap the links
see zena 1.0

Display a language selector:

<div id='lang' do='lang_links'/>

Display a language selector wrapped in p tags:

<div id='lang' do='lang_links' join=' | ' wrap='p'/>

The current language is highlighted with <em> when no wrap tag is specified. Otherwise, “on” class is added to the wrap tag. Example:

<p class='on'>en</p> | <p>fr</p>

If you need to customize further, you can use a block on site.lang_list (list of strings like “en”, “fr”, etc):

<ul do='site.lang_list'>
  <li do='each' class='#{this == visitor.lang ? "on" : "off"}' do='eval'>zen_path(@node, :lang => this)</li>
</ul>

The code above uses two special constructs: “this”, which means “current context’s object” (a string like “en” in this case) and ”@node” to find the last context where the current object was a Node (in this case this is just before the <ul> tag).