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

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

Set up
======

Create an address book:

>>> from icemac.addressbook.testing import create_addressbook
>>> create_addressbook()
<AddressBook u'ab' (u'test address book')>

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

>>> from z3c.etestbrowser.wsgi import ExtendedTestBrowser as Browser
>>> browser = Browser()
>>> browser.addHeader('Authorization', 'Basic editor: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.addHeader('Authorization', 'Basic editor:editor')
>>> en_browser.open('http://localhost/++skin++AddressBook/ab')
>>> 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>
       <legend>Person</legend>
       <div class="group">
           <div class="status">
             <ul class="errors">
          <li>
              Familienname:
  <div class="error">Erforderliche Eingabe fehlt.</div>
          </li>
        </ul>
           </div>
  ...
