Commit 3f39074f authored by Michal Čihař's avatar Michal Čihař

Merge branch 'pyuca'

parents e32cd7d9 4a234cc2
...@@ -17,3 +17,4 @@ weblate-*.tar.* ...@@ -17,3 +17,4 @@ weblate-*.tar.*
*.sublime-* *.sublime-*
/Weblate.egg-info/ /Weblate.egg-info/
/build/ /build/
/pyuca
...@@ -21,8 +21,6 @@ before_install: ...@@ -21,8 +21,6 @@ before_install:
- git clone --depth 1 --branch v0.1.2 https://github.com/ruleant/buildtime-trend.git $HOME/buildtime-trend - git clone --depth 1 --branch v0.1.2 https://github.com/ruleant/buildtime-trend.git $HOME/buildtime-trend
- source $HOME/buildtime-trend/init.sh - source $HOME/buildtime-trend/init.sh
- timestamp.sh packages - timestamp.sh packages
- sudo apt-get update -qq
- sudo apt-get install git libicu-dev
# commands to install dependencies # commands to install dependencies
install: install:
- timestamp.sh install - timestamp.sh install
...@@ -32,8 +30,6 @@ install: ...@@ -32,8 +30,6 @@ install:
before_script: before_script:
- timestamp.sh before_script - timestamp.sh before_script
- ./ci/setup-env - ./ci/setup-env
- echo -e "[server]\nmax_allowed_packet=64M\nwait_timeout=28800" | sudo tee -a /etc/mysql/conf.d/weblate.cnf
- sudo service mysql restart
# commands to run tests # commands to run tests
script: script:
- timestamp.sh tests - timestamp.sh tests
...@@ -48,6 +44,7 @@ cache: ...@@ -48,6 +44,7 @@ cache:
apt: true apt: true
directories: directories:
- $HOME/.pip-cache/ - $HOME/.pip-cache/
sudo: false
matrix: matrix:
allow_failures: allow_failures:
- python: "2.7" - python: "2.7"
......
...@@ -4,6 +4,7 @@ set -e ...@@ -4,6 +4,7 @@ set -e
set -x set -x
pip install $CI_DJANGO pip install $CI_DJANGO
pip install https://github.com/SmileyChris/pyuca/archive/master.zip
pip install \ pip install \
-r requirements-optional.txt \ -r requirements-optional.txt \
-r requirements-django-1.6.txt \ -r requirements-django-1.6.txt \
......
...@@ -32,8 +32,8 @@ dateutil ...@@ -32,8 +32,8 @@ dateutil
http://labix.org/python-dateutil http://labix.org/python-dateutil
libravatar (optional for federated avatar support) libravatar (optional for federated avatar support)
https://pypi.python.org/pypi/pyLibravatar https://pypi.python.org/pypi/pyLibravatar
PyICU (optional for proper sorting of strings) pyuca (optional for proper sorting of strings)
https://pypi.python.org/pypi/PyICU https://github.com/jtauber/pyuca
babel (optional for Android resources support) babel (optional for Android resources support)
http://babel.pocoo.org/ http://babel.pocoo.org/
Database backend Database backend
...@@ -49,7 +49,7 @@ you can use apt-get: ...@@ -49,7 +49,7 @@ you can use apt-get:
apt-get install python-django translate-toolkit \ apt-get install python-django translate-toolkit \
python-whoosh python-pil python-django-south python-libravatar \ python-whoosh python-pil python-django-south python-libravatar \
python-pyicu python-babel python-babel
# Optional for database backend # Optional for database backend
...@@ -80,7 +80,7 @@ All requirements are available either directly in openSUSE or in ...@@ -80,7 +80,7 @@ All requirements are available either directly in openSUSE or in
.. code-block:: sh .. 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-Whoosh python-Pillow python-South python-python-social-auth \
python-babel python-babel
...@@ -414,16 +414,16 @@ you install `pyLibavatar`_, you will get proper support for federated avatars. ...@@ -414,16 +414,16 @@ you install `pyLibavatar`_, you will get proper support for federated avatars.
.. _pyLibavatar: https://pypi.python.org/pypi/pyLibravatar .. _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 way language names are properly sorted even in non-ASCII languages like
Japanese, Chinese or Arabic or for languages with accented letters. 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: .. _production-secret:
......
-r requirements.txt -r requirements.txt
PyICU pyuca
pyLibravatar pyLibravatar
pydns pydns
babel babel
......
...@@ -34,10 +34,10 @@ import unicodedata ...@@ -34,10 +34,10 @@ import unicodedata
import weblate import weblate
try: try:
import icu # pylint: disable=import-error import pyuca # pylint: disable=import-error
HAS_ICU = True HAS_PYUCA = True
except ImportError: except ImportError:
HAS_ICU = False HAS_PYUCA = False
def remove_accents(input_str): def remove_accents(input_str):
...@@ -53,20 +53,18 @@ def sort_choices(choices): ...@@ -53,20 +53,18 @@ def sort_choices(choices):
''' '''
Sorts choices alphabetically. Sorts choices alphabetically.
Either using cmp or ICU. Either using cmp or pyuca.
''' '''
if not HAS_ICU: if not HAS_PYUCA:
return sorted( return sorted(
choices, choices,
key=lambda tup: remove_accents(tup[1]) key=lambda tup: remove_accents(tup[1]).lower()
) )
else: else:
locale = icu.Locale(get_language()) collator = pyuca.Collator()
collator = icu.Collator.createInstance(locale)
return sorted( return sorted(
choices, choices,
key=lambda tup: tup[1], key=lambda tup: collator.sort_key(unicode(tup[1]))
cmp=collator.compare
) )
......
...@@ -53,15 +53,15 @@ def get_optional_versions(): ...@@ -53,15 +53,15 @@ def get_optional_versions():
''' '''
result = [] result = []
name = 'ICU' name = 'pyuca'
url = 'https://pypi.python.org/pypi/PyICU' url = 'https://github.com/jtauber/pyuca'
mod = get_version_module('icu', name, url, True) mod = get_version_module('pyuca', name, url, True)
if mod is not None: if mod is not None:
result.append(( result.append((
name, name,
url, url,
mod.VERSION, 'N/A',
'1.0', None,
)) ))
name = 'pyLibravatar' name = 'pyLibravatar'
......
...@@ -28,7 +28,7 @@ from django.conf import settings ...@@ -28,7 +28,7 @@ from django.conf import settings
from weblate import settings_example from weblate import settings_example
from weblate import appsettings from weblate import appsettings
from weblate.accounts.avatar import HAS_LIBRAVATAR 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 from weblate.trans.util import get_configuration_errors, get_clean_env
import weblate import weblate
import django import django
...@@ -138,11 +138,11 @@ def performance(request): ...@@ -138,11 +138,11 @@ def performance(request):
HAS_LIBRAVATAR, HAS_LIBRAVATAR,
'production-avatar', 'production-avatar',
)) ))
# PyICU library # pyuca library
checks.append(( checks.append((
_('PyICU library'), _('pyuca library'),
HAS_ICU, HAS_PYUCA,
'production-pyicu', 'production-pyuca',
)) ))
# Cookie signing key # Cookie signing key
checks.append(( 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