Text File
i18nfile.txt

I18nFile tests

First, let's create an I18nFile instance:

>>> print http(r"""
... POST /@@contents.html HTTP/1.1
... Authorization: Basic mgr:mgrpw
... """, form={"type_name": "BrowserAdd__zope.app.i18nfile.i18nfile.I18nFile",
...            "new_value": "i18nfile"})
HTTP/1.1 303 See Other
...

Then add some sample data for default (en) language:

>>> print http(r"""
... POST /i18nfile/edit.html HTTP/1.1
... Authorization: Basic mgr:mgrpw
... """, form={"contentType": "text/plain",
...            "defaultLanguage": "en",
...            "language": "en",
...            "newLanguage": "",
...            "data": "English",
...            "edit": "Save"})
HTTP/1.1 303 See Other
...

Ok, now we can view the data in the edit form:

>>> print http(r"""
... GET /i18nfile/editForm.html?language=en HTTP/1.1
... Authorization: Basic mgr:mgrpw
... """)
HTTP/1.1 200 OK
...
        <textarea ...>English</textarea>
...

and as file content:

>>> print http(r"""
... GET /i18nfile/index.html HTTP/1.1
... Authorization: Basic mgr:mgrpw
... """)
HTTP/1.1 200 OK
...
English

Let's add new (russian) language:

>>> print http(r"""
... POST /i18nfile/edit.html HTTP/1.1
... Authorization: Basic mgr:mgrpw
... """, form={"contentType": "text/plain",
...            "defaultLanguage": "en",
...            "language": "en",
...            "addLanguage": "Add new language",
...            "newLanguage": "ru",
...            "data": "English"})
HTTP/1.1 303 See Other
...

and add some sample data for russian (ru) language:

>>> print http(r"""
... POST /i18nfile/edit.html HTTP/1.1
... Authorization: Basic mgr:mgrpw
... """, form={"contentType": "text/plain",
...            "defaultLanguage": "en",
...            "language": "ru",
...            "newLanguage": "",
...            "data": "Russian",
...            "edit": "Save"})
HTTP/1.1 303 See Other
...

Then we can view sample data for russain language in the edit form:

>>> print http(r"""
... GET /i18nfile/editForm.html?language=ru HTTP/1.1
... Authorization: Basic mgr:mgrpw
... """)
HTTP/1.1 200 OK
...
        <textarea ...>Russian</textarea>
...

and if our preferred language is russian as file content:

>>> print http(r"""
... GET /i18nfile/index.html HTTP/1.1
... Authorization: Basic mgr:mgrpw
... Accept-Language: ru,en
... """)
HTTP/1.1 200 OK
...
Russian