Repository: google/personfinder

Issue:
Try removing the hack for lang=zh-HK
We have implemented a hack to treat lang=zh-HK as lang=zhhk to workaround a bug in Django. The bug  may be fixed by upgrading Django to 1.4. Let's try removing the hack and just use lang=zh-HK as is.



Discussion:
I am working on this issue. 
After renamed `zhhk` to `zh-HK`

`$ mv personfinder/app/locale/zhhkt personfinder/app/locale/zh-HK`

I ran tests (everything seems to be ok).
But I found an error
```
Traceback (most recent call last):
  File "/opt/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 310, in _handle_POST
    api_response = _execute_request(request).Encode()
  File "/opt/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 199, in _execute_request
    make_request()
  File "/opt/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 191, in make_request
    request_id)
  File "/opt/google_appengine/google/appengine/api/images/images_not_implemented_stub.py", line 54, in MakeSyncCall
    raise NotImplementedError('Unable to find the Python PIL library.  Please '
NotImplementedError: Unable to find the Python PIL library.  Please view the SDK documentation for details about installing PIL on your system.
```

I am working with Docker, so I wondering if `pillow` needs to be installed on development environment ? If yes, we could add `pillow` to the `Dockerfile` 
Thanks for working on this!

Yes, running tests requires PIL. Adding PIL to Dockerfile sounds good.

BTW If you run tests without PIL and found only photo-related tests fail, then that should be fine. It's unlikely that this change affects photo features.

When you work on this change, can you also remove workarounds in code which handles "zhhk" locale? You can find them here:
https://github.com/google/personfinder/search?utf8=%E2%9C%93&q=zhhk

Resolving patch:
diff --git a/app/const.py b/app/const.py
--- a/app/const.py
+++ b/app/const.py
@@ -211,18 +211,7 @@
     'mo' : 'ro',
     # Note that we don't currently support jv (Javanese) or yi (Yiddish).
     'jw' : 'jv',
-    'ji' : 'yi',
-    # Django has a bug that django.utils.translation.activate() throws
-    # AttributeError when:
-    # - The language is not in $APPENGINE_DIR/lib/django_1_2/django/conf/locale
-    # - The language code contains a dash '-'
-    # and 'zh-HK' meets both criteria. We workaround this bug by using 'zhhk'
-    # instead of 'zh-HK' internally.
-    #
-    # The cause of the bug is that
-    # $APPENGINE_DIR/lib/django_1_2/django/utils/translation/trans_real.py:142
-    # accesses res._info even when res is None.
-    'zh-HK': 'zhhk',
+    'ji' : 'yi'
 }
 
 # RTL languages.
diff --git a/app/utils.py b/app/utils.py
--- a/app/utils.py
+++ b/app/utils.py
@@ -847,11 +847,6 @@ def handle_exception(self, exception, debug_mode):
 
     def __get_env_language_for_babel(self):
         language_code = self.env.lang
-        # A hack to avoid rejecting zh-hk locale.
-        # This corresponds to the hack with LANGUAGE_SYNONYMS in const.py.
-        # TODO: remove these 2 lines when a original code can be passed to here.
-        if language_code == 'zhhk':
-            language_code = 'zh-hk'
         try:
             return babel.Locale.parse(language_code, sep='-')
         except babel.UnknownLocaleError as e:


Test patch: