Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/okfn/ckan
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones committed Mar 27, 2012
2 parents e37f006 + cbb9c28 commit 3933e33
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
26 changes: 20 additions & 6 deletions ckan/lib/helpers.py
Expand Up @@ -105,13 +105,27 @@ def _add_i18n_to_url(url_to_amend, **kw):
root = request.environ.get('SCRIPT_NAME', '')
except TypeError:
root = ''
if default_locale:
url = url_to_amend
# ckan.root_path is defined when we have none standard language
# position in the url
root_path = config.get('ckan.root_path')
if root_path:
# we have a special root specified so use that
if default_locale:
root = re.sub('/{{LANG}}', '', root_path)
else:
root = re.sub('{{LANG}}', locale, root_path)
# make sure we don't have a trailing / on the root
if root[-1] == '/':
root = root[:-1]
url = '%s%s' % (root, url_to_amend)
else:
# we need to strip the root from the url and the add it before
# the language specification.
url = url_to_amend[len(root):]
url = '%s/%s%s' % (root, locale, url)
if default_locale:
url = url_to_amend
else:
# we need to strip the root from the url and the add it before
# the language specification.
url = url_to_amend[len(root):]
url = '%s/%s%s' % (root, locale, url)

# stop the root being added twice in redirects
if no_root:
Expand Down
2 changes: 2 additions & 0 deletions doc/i18n.rst
Expand Up @@ -4,6 +4,8 @@ Internationalize CKAN

CKAN is used in many countries, and adding a new language to the web interface is a simple process.

CKAN uses the url to determine which language is used. An example would be ``/fr/dataset`` would be shown in french. If CKAN is running under a directory then an example would be ``/root/fr/dataset``. For custom paths the ``ckan.root_path`` config option can be used and is of the form ``/path/from/root/with/{{LANG}}/substitution``.

.. Note: Storing metadata field values in more than one language is a separate topic. This is achieved by storing the translations in extra fields. A custom dataset form and dataset display template are recommended. Ask the CKAN team for more information.
Supported Languages
Expand Down

0 comments on commit 3933e33

Please sign in to comment.