[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] [PATCH ocitysmap] First support for Croatian. Handling
From: |
David MENTRE |
Subject: |
[Maposmatic-dev] [PATCH ocitysmap] First support for Croatian. Handling of Croatian accents |
Date: |
Wed, 20 Jan 2010 22:39:44 +0100 |
---
ocitysmap/i18n.py | 43 ++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 42 insertions(+), 1 deletions(-)
diff --git a/ocitysmap/i18n.py b/ocitysmap/i18n.py
index e70b286..1c4d483 100644
--- a/ocitysmap/i18n.py
+++ b/ocitysmap/i18n.py
@@ -44,7 +44,7 @@ class i18n:
pass
class i18n_template_code_CODE(i18n):
- def __init__(self, language, language_path):
+ def __init__(self, language, locale_path):
"""Install the _() function for the chosen locale other
object initialisation"""
self.language = str(language) # FIXME: why do we have unicode here?
@@ -537,6 +537,46 @@ class i18n_nl_generic(i18n):
def first_letter_equal(self, a, b):
return self._upper_unaccent_string(a) == self._upper_unaccent_string(b)
+class i18n_hr_HR(i18n):
+ # for _upper_unaccent_string
+ C_ACCENT = re.compile(ur"[ÄÄ]", re.IGNORECASE | re.UNICODE)
+ D_ACCENT = re.compile(ur"Ä|dž", re.IGNORECASE | re.UNICODE)
+ N_ACCENT = re.compile(ur"nj", re.IGNORECASE | re.UNICODE)
+ L_ACCENT = re.compile(ur"lj", re.IGNORECASE | re.UNICODE)
+ S_ACCENT = re.compile(ur"Å¡", re.IGNORECASE | re.UNICODE)
+ Z_ACCENT = re.compile(ur"ž", re.IGNORECASE | re.UNICODE)
+
+ def _upper_unaccent_string(self, s):
+ s = self.C_ACCENT.sub("c", s)
+ s = self.D_ACCENT.sub("d", s)
+ s = self.N_ACCENT.sub("n", s)
+ s = self.L_ACCENT.sub("l", s)
+ s = self.S_ACCENT.sub("s", s)
+ s = self.Z_ACCENT.sub("z", s)
+ return s.upper()
+
+ def __init__(self, language, locale_path):
+ """Install the _() function for the chosen locale other
+ object initialisation"""
+ self.language = str(language) # FIXME: why do we have unicode here?
+ _install_language(language, locale_path)
+
+ def language_code(self):
+ """returns the language code of the specific language
+ supported, e.g. fr_FR.UTF-8"""
+ return self.language
+
+ def user_readable_street(self, name):
+ """ transforms a street name into a suitable form for
+ the map index, e.g. Paris (Rue de) for French"""
+ return name
+
+ ## FIXME: only first letter does not work for Croatian digraphs (dž, lj,
nj)
+ def first_letter_equal(self, a, b):
+ """returns True if the letters a and b are equal in the map index,
+ e.g. Ã and E are equals in French map index"""
+ return self._upper_unaccent_string(a) == self._upper_unaccent_string(b)
+
class i18n_generic(i18n):
def __init__(self, language, locale_path):
@@ -609,6 +649,7 @@ language_class_map = {
'ar_SY.UTF-8': i18n_ar_generic,
'ar_TN.UTF-8': i18n_ar_generic,
'ar_YE.UTF-8': i18n_ar_generic,
+ 'hr_HR.UTF-8': i18n_hr_HR,
'ru_RU.UTF-8': i18n_ru_generic,
}
--
1.6.0.4
- [Maposmatic-dev] [PATCH ocitysmap] First support for Croatian. Handling of Croatian accents,
David MENTRE <=