===========
Translation
===========

The whole UI was translated into German. There are some tricky edges,
which are tested here.

Set up
======

Create a browser and log in an editor which preferes German:

>>> from icemac.addressbook.testing import Browser
>>> browser = Browser()
>>> browser.login('editor')
>>> browser.addHeader('Accept-Language', 'de-DE')
>>> browser.open('http://localhost/++skin++AddressBook/ab')


Translation of country name
===========================

The country names are translated in the country dropdown:

>>> from icemac.addressbook.testing import get_messages
>>> browser.getLink('Person', index=1).click()
>>> browser.getControl('Land').displayValue
['Deutschland']
>>> browser.getControl('Land').displayValue = ['Schweiz']
>>> browser.getControl('Ort').value = 'Thun'
>>> browser.getControl('Familienname').value = 'Deutsch'
>>> browser.getControl('Hinzufügen').click()
>>> get_messages(browser)
[u'\u201eDeutsch\u201c hinzugef\xfcgt.']

The the main postal address drop down is also translated:

>>> browser.getLink('Deutsch').click()
>>> browser.getControl('wichtigste Anschrift').displayValue
['Thun, Schweiz']
>>> browser.getControl('Abbrechen').click()
>>> get_messages(browser)
[u'Keine \xc4nderungen durchgef\xfchrt.']

A user who prefers English (default) sees the English translation of the
country name:

>>> en_browser = Browser()
>>> en_browser.login('editor')
>>> en_browser.open('http://localhost/ab/person-list.html')
>>> en_browser.getLink('Deutsch').click()
>>> en_browser.getControl('main postal address').displayValue
['Thun, Switzerland']


Translation of error messages
=============================

Some error messages are translated using `zope.app.locales`, this test makes
sure that this package is installed:

>>> browser.getLink('Person', index=1).click()
>>> browser.getControl('Hinzufügen').click()
>>> print browser.contents
<!DOCTYPE ...
     <fieldset class="ab">
       <legend>Person</legend>
       <div class="group">
           <div class="status">
             <ul class="errors">
          <li>
              Familienname:
  <div class="error">Erforderliche Eingabe fehlt.</div>
          </li>
        </ul>
           </div>
  ...
