prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Flask-Babel does not translate zh_TW and zh_CN
  ### CKAN Version if known (or site URL)
  
  ≧ 2.8.0
  
  ### Please describe the expected behaviour
  
  When switching to ``zh_TW`` or ``zh_CN`` languages on the pages written in Flask (ex. ``/`` and ``/user``), the pages should be shown in corresponding languages.
  
  ### Please describe the actual behaviour
  
  It shows English instead of ``zh_TW`` or ``zh_CN``.
  
  ### What steps can be taken to reproduce the issue? 
  
  Switch language to Chinese on the above-mentioned pages.
  
  </issue>
  <code>
  [start of ckan/views/home.py]
  1 # encoding: utf-8
  2 
  3 from flask import Blueprint, abort
  4 
  5 import ckan.model as model
  6 import ckan.logic as logic
  7 import ckan.lib.base as base
  8 import ckan.lib.search as search
  9 import ckan.lib.helpers as h
  10 
  11 from ckan.common import g, config, _
  12 
  13 CACHE_PARAMETERS = [u'__cache', u'__no_cache__']
  14 
  15 
  16 home = Blueprint(u'home', __name__)
  17 
  18 
  19 @home.before_request
  20 def before_request():
  21     u'''set context and check authorization'''
  22     try:
  23         context = {
  24             u'model': model,
  25             u'user': g.user,
  26             u'auth_user_obj': g.userobj}
  27         logic.check_access(u'site_read', context)
  28     except logic.NotAuthorized:
  29         abort(403)
  30 
  31 
  32 def index():
  33     u'''display home page'''
  34     try:
  35         context = {u'model': model, u'session': model.Session,
  36                    u'user': g.user, u'auth_user_obj': g.userobj}
  37         data_dict = {u'q': u'*:*',
  38                      u'facet.field': h.facets(),
  39                      u'rows': 4,
  40                      u'start': 0,
  41                      u'sort': u'view_recent desc',
  42                      u'fq': u'capacity:"public"'}
  43         query = logic.get_action(u'package_search')(context, data_dict)
  44         g.search_facets = query['search_facets']
  45         g.package_count = query['count']
  46         g.datasets = query['results']
  47 
  48         org_label = h.humanize_entity_type(
  49             u'organization',
  50             h.default_group_type(u'organization'),
  51             u'facet label') or _(u'Organizations')
  52 
  53         group_label = h.humanize_entity_type(
  54             u'group',
  55             h.default_group_type(u'group'),
  56             u'facet label') or _(u'Groups')
  57 
  58         g.facet_titles = {
  59             u'organization': org_label,
  60             u'groups': group_label,
  61             u'tags': _(u'Tags'),
  62             u'res_format': _(u'Formats'),
  63             u'license': _(u'Licenses'),
  64         }
  65 
  66     except search.SearchError:
  67         g.package_count = 0
  68 
  69     if g.userobj and not g.userobj.email:
  70         url = h.url_for(controller=u'user', action=u'edit')
  71         msg = _(u'Please <a href="%s">update your profile</a>'
  72                 u' and add your email address. ') % url + \
  73             _(u'%s uses your email address'
  74                 u' if you need to reset your password.') \
  75             % config.get(u'ckan.site_title')
  76         h.flash_notice(msg, allow_html=True)
  77     return base.render(u'home/index.html', extra_vars={})
  78 
  79 
  80 def about():
  81     u''' display about page'''
  82     return base.render(u'home/about.html', extra_vars={})
  83 
  84 
  85 util_rules = [
  86     (u'/', index),
  87     (u'/about', about)
  88 ]
  89 for rule, view_func in util_rules:
  90     home.add_url_rule(rule, view_func=view_func)
  91
  [end of ckan/views/home.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/ckan/views/home.py b/ckan/views/home.py
  --- a/ckan/views/home.py
  +++ b/ckan/views/home.py
  @@ -1,6 +1,6 @@
   # encoding: utf-8
   
  -from flask import Blueprint, abort
  +from flask import Blueprint, abort, redirect
   
   import ckan.model as model
   import ckan.logic as logic
  @@ -82,9 +82,36 @@
       return base.render(u'home/about.html', extra_vars={})
   
   
  +def redirect_locale(target_locale, path=None):
  +    target = f'/{target_locale}/{path}' if path else f'/{target_locale}'
  +    return redirect(target, code=308)
  +
  +
   util_rules = [
       (u'/', index),
       (u'/about', about)
   ]
   for rule, view_func in util_rules:
       home.add_url_rule(rule, view_func=view_func)
  +
  +locales_mapping = [
  +    ('zh_TW', 'zh_Hant_TW'),
  +    ('zh_CN', 'zh_Hans_CN'),
  +]
  +
  +for locale in locales_mapping:
  +
  +    legacy_locale = locale[0]
  +    new_locale = locale[1]
  +
  +    home.add_url_rule(
  +        f'/{legacy_locale}/',
  +        view_func=redirect_locale,
  +        defaults={'target_locale': new_locale}
  +    )
  +
  +    home.add_url_rule(
  +        f'/{legacy_locale}/<path:path>',
  +        view_func=redirect_locale,
  +        defaults={'target_locale': new_locale}
  +    )
  
verification_info: {"golden_diff": "diff --git a/ckan/views/home.py b/ckan/views/home.py\n--- a/ckan/views/home.py\n+++ b/ckan/views/home.py\n@@ -1,6 +1,6 @@\n # encoding: utf-8\n \n-from flask import Blueprint, abort\n+from flask import Blueprint, abort, redirect\n \n import ckan.model as model\n import ckan.logic as logic\n@@ -82,9 +82,36 @@\n     return base.render(u'home/about.html', extra_vars={})\n \n \n+def redirect_locale(target_locale, path=None):\n+    target = f'/{target_locale}/{path}' if path else f'/{target_locale}'\n+    return redirect(target, code=308)\n+\n+\n util_rules = [\n     (u'/', index),\n     (u'/about', about)\n ]\n for rule, view_func in util_rules:\n     home.add_url_rule(rule, view_func=view_func)\n+\n+locales_mapping = [\n+    ('zh_TW', 'zh_Hant_TW'),\n+    ('zh_CN', 'zh_Hans_CN'),\n+]\n+\n+for locale in locales_mapping:\n+\n+    legacy_locale = locale[0]\n+    new_locale = locale[1]\n+\n+    home.add_url_rule(\n+        f'/{legacy_locale}/',\n+        view_func=redirect_locale,\n+        defaults={'target_locale': new_locale}\n+    )\n+\n+    home.add_url_rule(\n+        f'/{legacy_locale}/<path:path>',\n+        view_func=redirect_locale,\n+        defaults={'target_locale': new_locale}\n+    )\n", "issue": "Flask-Babel does not translate zh_TW and zh_CN\n### CKAN Version if known (or site URL)\r\n\r\n\u2267 2.8.0\r\n\r\n### Please describe the expected behaviour\r\n\r\nWhen switching to ``zh_TW`` or ``zh_CN`` languages on the pages written in Flask (ex. ``/`` and ``/user``), the pages should be shown in corresponding languages.\r\n\r\n### Please describe the actual behaviour\r\n\r\nIt shows English instead of ``zh_TW`` or ``zh_CN``.\r\n\r\n### What steps can be taken to reproduce the issue? \r\n\r\nSwitch language to Chinese on the above-mentioned pages.\n", "before_files": [{"content": "# encoding: utf-8\n\nfrom flask import Blueprint, abort\n\nimport ckan.model as model\nimport ckan.logic as logic\nimport ckan.lib.base as base\nimport ckan.lib.search as search\nimport ckan.lib.helpers as h\n\nfrom ckan.common import g, config, _\n\nCACHE_PARAMETERS = [u'__cache', u'__no_cache__']\n\n\nhome = Blueprint(u'home', __name__)\n\n\n@home.before_request\ndef before_request():\n    u'''set context and check authorization'''\n    try:\n        context = {\n            u'model': model,\n            u'user': g.user,\n            u'auth_user_obj': g.userobj}\n        logic.check_access(u'site_read', context)\n    except logic.NotAuthorized:\n        abort(403)\n\n\ndef index():\n    u'''display home page'''\n    try:\n        context = {u'model': model, u'session': model.Session,\n                   u'user': g.user, u'auth_user_obj': g.userobj}\n        data_dict = {u'q': u'*:*',\n                     u'facet.field': h.facets(),\n                     u'rows': 4,\n                     u'start': 0,\n                     u'sort': u'view_recent desc',\n                     u'fq': u'capacity:\"public\"'}\n        query = logic.get_action(u'package_search')(context, data_dict)\n        g.search_facets = query['search_facets']\n        g.package_count = query['count']\n        g.datasets = query['results']\n\n        org_label = h.humanize_entity_type(\n            u'organization',\n            h.default_group_type(u'organization'),\n            u'facet label') or _(u'Organizations')\n\n        group_label = h.humanize_entity_type(\n            u'group',\n            h.default_group_type(u'group'),\n            u'facet label') or _(u'Groups')\n\n        g.facet_titles = {\n            u'organization': org_label,\n            u'groups': group_label,\n            u'tags': _(u'Tags'),\n            u'res_format': _(u'Formats'),\n            u'license': _(u'Licenses'),\n        }\n\n    except search.SearchError:\n        g.package_count = 0\n\n    if g.userobj and not g.userobj.email:\n        url = h.url_for(controller=u'user', action=u'edit')\n        msg = _(u'Please <a href=\"%s\">update your profile</a>'\n                u' and add your email address. ') % url + \\\n            _(u'%s uses your email address'\n                u' if you need to reset your password.') \\\n            % config.get(u'ckan.site_title')\n        h.flash_notice(msg, allow_html=True)\n    return base.render(u'home/index.html', extra_vars={})\n\n\ndef about():\n    u''' display about page'''\n    return base.render(u'home/about.html', extra_vars={})\n\n\nutil_rules = [\n    (u'/', index),\n    (u'/about', about)\n]\nfor rule, view_func in util_rules:\n    home.add_url_rule(rule, view_func=view_func)\n", "path": "ckan/views/home.py"}]}