Commit 74632325 authored by Michal Čihař's avatar Michal Čihař

Switch to pyuca for sorting

Fixes #581
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 5df11e4a
......@@ -17,3 +17,4 @@ weblate-*.tar.*
*.sublime-*
/Weblate.egg-info/
/build/
/pyuca
......@@ -21,8 +21,6 @@ before_install:
- git clone --depth 1 --branch v0.1.2 https://github.com/ruleant/buildtime-trend.git $HOME/buildtime-trend
- source $HOME/buildtime-trend/init.sh
- timestamp.sh packages
- sudo apt-get update -qq
- sudo apt-get install git libicu-dev
# commands to install dependencies
install:
- timestamp.sh install
......@@ -48,6 +46,7 @@ cache:
apt: true
directories:
- $HOME/.pip-cache/
sudo: false
matrix:
allow_failures:
- python: "2.7"
......
......@@ -4,6 +4,7 @@ set -e
set -x
pip install $CI_DJANGO
pip install https://github.com/SmileyChris/pyuca/archive/master.zip
pip install \
-r requirements-optional.txt \
-r requirements-django-1.6.txt \
......
......@@ -32,8 +32,8 @@ dateutil
http://labix.org/python-dateutil
libravatar (optional for federated avatar support)
https://pypi.python.org/pypi/pyLibravatar
PyICU (optional for proper sorting of strings)
https://pypi.python.org/pypi/PyICU
pyuca (optional for proper sorting of strings)
https://github.com/jtauber/pyuca
babel (optional for Android resources support)
http://babel.pocoo.org/
Database backend
......@@ -49,7 +49,7 @@ you can use apt-get:
apt-get install python-django translate-toolkit \
python-whoosh python-pil python-django-south python-libravatar \
python-pyicu python-babel
python-babel
# Optional for database backend
......@@ -80,7 +80,7 @@ All requirements are available either directly in openSUSE or in
.. code-block:: sh
zypper install python-Django python-icu translate-toolkit \
zypper install python-Django translate-toolkit \
python-Whoosh python-Pillow python-South python-python-social-auth \
python-babel
......@@ -414,16 +414,16 @@ you install `pyLibavatar`_, you will get proper support for federated avatars.
.. _pyLibavatar: https://pypi.python.org/pypi/pyLibravatar
.. _production-pyicu:
.. _production-pyuca:
PyICU library
pyuca library
+++++++++++++
`PyICU`_ library is optionally used by Weblate to sort Unicode strings. This
`pyuca`_ library is optionally used by Weblate to sort Unicode strings. This
way language names are properly sorted even in non-ASCII languages like
Japanese, Chinese or Arabic or for languages with accented letters.
.. _PyICU: https://pypi.python.org/pypi/PyICU
.. _pyuca: https://github.com/jtauber/pyuca
.. _production-secret:
......
-r requirements.txt
PyICU
pyuca
pyLibravatar
babel
Mercurial>=2.8
......@@ -34,10 +34,10 @@ import unicodedata
import weblate
try:
import icu # pylint: disable=import-error
HAS_ICU = True
import pyuca # pylint: disable=import-error
HAS_PYUCA = True
except ImportError:
HAS_ICU = False
HAS_PYUCA = False
def remove_accents(input_str):
......@@ -53,20 +53,18 @@ def sort_choices(choices):
'''
Sorts choices alphabetically.
Either using cmp or ICU.
Either using cmp or pyuca.
'''
if not HAS_ICU:
if not HAS_PYUCA:
return sorted(
choices,
key=lambda tup: remove_accents(tup[1])
key=lambda tup: remove_accents(tup[1]).lower()
)
else:
locale = icu.Locale(get_language())
collator = icu.Collator.createInstance(locale)
collator = pyuca.Collator()
return sorted(
choices,
key=lambda tup: tup[1],
cmp=collator.compare
key=lambda tup: collator.sort_key(unicode(tup[1]))
)
......
......@@ -53,15 +53,15 @@ def get_optional_versions():
'''
result = []
name = 'ICU'
url = 'https://pypi.python.org/pypi/PyICU'
mod = get_version_module('icu', name, url, True)
name = 'pyuca'
url = 'https://github.com/jtauber/pyuca'
mod = get_version_module('pyuca', name, url, True)
if mod is not None:
result.append((
name,
url,
mod.VERSION,
'1.0',
'N/A',
None,
))
name = 'pyLibravatar'
......
......@@ -28,7 +28,7 @@ from django.conf import settings
from weblate import settings_example
from weblate import appsettings
from weblate.accounts.avatar import HAS_LIBRAVATAR
from weblate.accounts.forms import HAS_ICU
from weblate.accounts.forms import HAS_PYUCA
from weblate.trans.util import get_configuration_errors, get_clean_env
import weblate
import django
......@@ -138,11 +138,11 @@ def performance(request):
HAS_LIBRAVATAR,
'production-avatar',
))
# PyICU library
# pyuca library
checks.append((
_('PyICU library'),
HAS_ICU,
'production-pyicu',
_('pyuca library'),
HAS_PYUCA,
'production-pyuca',
))
# Cookie signing key
checks.append((
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment