[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Maposmatic-dev] Catalan language code, first attempt
From: |
Joan Montané |
Subject: |
[Maposmatic-dev] Catalan language code, first attempt |
Date: |
Wed, 6 Jan 2010 18:03:44 +0100 |
Hi all,
I have attached ocitysmap.po for Catalan language, please, commit it to trunk.
Following, the class i18n_ca_generic code, it's a first aproach with
more common description of ways in Catalan and Spanish (OSM data is
mixed with several languages in Catalan speakers area).
The settings.py code should be
"ca_ES.UTF-8", u"Catalan"
Also, I want help for coding "reader street names". If I understand
well, the current code does this:
Carrer del Mar ---> Mar (Carrer del)
But I want this:
Carrer del Mar --> Mar, c.
The abbreviations are knowed. But I don't nothing about regex, any help?
Yours,
Joan Montané
---------------------------------------
class i18n_ca_generic(i18n):
APPELLATIONS = [ u"Avenida", u"Avinguda", u"Calle", u"Camino",
u"Camí", u"Carrer",
u"Carretera", u"Plaza", u"Plaça", u"Ronda" ]
DETERMINANTS = [ u" de", u" de la", u" del", u" de las",
u" dels", u" de los", u" d'", u" de l'", u"de sa", u"de son", u"de
s'", u"de ses", u"d'en", u"de na", u"de n'", u"" ]
SPACE_REDUCE = re.compile(r"\s+")
PREFIX_REGEXP = re.compile(r"^(?P<prefix>(%s)(%s)?)\s?\b(?P<name>.+)" %
("|".join(APPELLATIONS),
"|".join(DETERMINANTS)), re.IGNORECASE
| re.UNICODE)
# for IndexPageGenerator._upper_unaccent_string
E_ACCENT = re.compile(ur"[éèêëẽ]", re.IGNORECASE | re.UNICODE)
I_ACCENT = re.compile(ur"[íìîïĩ]", re.IGNORECASE | re.UNICODE)
A_ACCENT = re.compile(ur"[áàâäã]", re.IGNORECASE | re.UNICODE)
O_ACCENT = re.compile(ur"[óòôöõ]", re.IGNORECASE | re.UNICODE)
U_ACCENT = re.compile(ur"[úùûüũ]", re.IGNORECASE | re.UNICODE)
N_ACCENT = re.compile(ur"[ñ]", re.IGNORECASE | re.UNICODE)
C_ACCENT = re.compile(ur"[ç]", re.IGNORECASE | re.UNICODE)
def __init__(self, language, locale_path):
self.language = str(language)
_install_language(language, locale_path)
def _upper_unaccent_string(self, s):
s = self.E_ACCENT.sub("e", s)
s = self.I_ACCENT.sub("i", s)
s = self.A_ACCENT.sub("a", s)
s = self.O_ACCENT.sub("o", s)
s = self.U_ACCENT.sub("u", s)
s = self.N_ACCENT.sub("n", s)
s = self.C_ACCENT.sub("c", s)
return s.upper()
def language_code(self):
return self.language
def user_readable_street(self, name):
name = name.strip()
name = self.SPACE_REDUCE.sub(" ", name)
name = self.PREFIX_REGEXP.sub(r"\g<name> (\g<prefix>)", name)
return name
def first_letter_equal(self, a, b):
return self._upper_unaccent_string(a) == self._upper_unaccent_string(b)
ocitysmap.po
Description: Binary data
- [Maposmatic-dev] Catalan language code, first attempt,
Joan Montané <=