forked from CGM_Public/pretix_original
Add Spanish (LatAm) and improve how we count language coverage (Z#23200505) (#5308)
* Add Spanish (LatAm) and improve how we count language coverage * Apply suggestions from code review Co-authored-by: Richard Schreiber <schreiber@rami.io> * Fix license header --------- Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
@@ -115,6 +115,7 @@ ALL_LANGUAGES = [
|
|||||||
('sk', _('Slovak')),
|
('sk', _('Slovak')),
|
||||||
('sv', _('Swedish')),
|
('sv', _('Swedish')),
|
||||||
('es', _('Spanish')),
|
('es', _('Spanish')),
|
||||||
|
('es-419', _('Spanish (Latin America)')),
|
||||||
('tr', _('Turkish')),
|
('tr', _('Turkish')),
|
||||||
('uk', _('Ukrainian')),
|
('uk', _('Ukrainian')),
|
||||||
]
|
]
|
||||||
@@ -172,6 +173,12 @@ EXTRA_LANG_INFO = {
|
|||||||
'name': 'Norwegian Bokmal',
|
'name': 'Norwegian Bokmal',
|
||||||
'name_local': 'norsk (bokmål)',
|
'name_local': 'norsk (bokmål)',
|
||||||
},
|
},
|
||||||
|
'es-419': {
|
||||||
|
'bidi': False,
|
||||||
|
'code': 'es-419',
|
||||||
|
'name': 'Spanish (Latin America)',
|
||||||
|
'name_local': 'Español',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
django.conf.locale.LANG_INFO.update(EXTRA_LANG_INFO)
|
django.conf.locale.LANG_INFO.update(EXTRA_LANG_INFO)
|
||||||
|
|||||||
35
src/pretix/base/management/commands/makemessages.py
Normal file
35
src/pretix/base/management/commands/makemessages.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#
|
||||||
|
# This file is part of pretix (Community Edition).
|
||||||
|
#
|
||||||
|
# Copyright (C) 2014-2020 Raphael Michel and contributors
|
||||||
|
# Copyright (C) 2020-2021 rami.io GmbH and contributors
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
|
||||||
|
# Public License as published by the Free Software Foundation in version 3 of the License.
|
||||||
|
#
|
||||||
|
# ADDITIONAL TERMS APPLY: Pursuant to Section 7 of the GNU Affero General Public License, additional terms are
|
||||||
|
# applicable granting you additional permissions and placing additional restrictions on your usage of this software.
|
||||||
|
# Please refer to the pretix LICENSE file to obtain the full terms applicable to this work. If you did not receive
|
||||||
|
# this file, see <https://pretix.eu/about/en/license>.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||||
|
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||||
|
# details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License along with this program. If not, see
|
||||||
|
# <https://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
import re
|
||||||
|
|
||||||
|
from django.core.management.commands import makemessages
|
||||||
|
|
||||||
|
|
||||||
|
def is_valid_locale(locale):
|
||||||
|
return re.match(r"^[a-z]+$", locale) or re.match(r"^[a-z]+_[A-Z0-9].*$", locale)
|
||||||
|
|
||||||
|
|
||||||
|
makemessages.is_valid_locale = is_valid_locale
|
||||||
|
|
||||||
|
|
||||||
|
class Command(makemessages.Command):
|
||||||
|
pass
|
||||||
@@ -32,7 +32,6 @@ from django.conf import settings
|
|||||||
from django.utils import translation
|
from django.utils import translation
|
||||||
from django.utils.formats import get_format
|
from django.utils.formats import get_format
|
||||||
from django.utils.translation import to_locale
|
from django.utils.translation import to_locale
|
||||||
from django.utils.translation.trans_real import TranslationCatalog
|
|
||||||
|
|
||||||
date_conversion_to_moment = {
|
date_conversion_to_moment = {
|
||||||
'%a': 'ddd',
|
'%a': 'ddd',
|
||||||
@@ -175,7 +174,7 @@ def get_language_score(locale):
|
|||||||
|
|
||||||
Note that there is no valid score for "en", since it's technically not "translated".
|
Note that there is no valid score for "en", since it's technically not "translated".
|
||||||
"""
|
"""
|
||||||
catalog = None
|
catalog = {}
|
||||||
app_configs = reversed(apps.get_app_configs())
|
app_configs = reversed(apps.get_app_configs())
|
||||||
|
|
||||||
for app in app_configs:
|
for app in app_configs:
|
||||||
@@ -198,10 +197,15 @@ def get_language_score(locale):
|
|||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
if catalog is None:
|
|
||||||
catalog = TranslationCatalog(translation)
|
catalog.update(translation._catalog.copy())
|
||||||
else:
|
|
||||||
catalog.update(translation)
|
# Also add fallback catalog (e.g. es for es-419, de for de-informal, …)
|
||||||
|
while translation._fallback:
|
||||||
|
if not locale.startswith(translation._fallback.info().get("language", "XX")):
|
||||||
|
break
|
||||||
|
translation = translation._fallback
|
||||||
|
catalog.update(translation._catalog.copy())
|
||||||
|
|
||||||
# Add pretix' main translation folder as well as installation-specific translation folders
|
# Add pretix' main translation folder as well as installation-specific translation folders
|
||||||
for localedir in reversed(settings.LOCALE_PATHS):
|
for localedir in reversed(settings.LOCALE_PATHS):
|
||||||
@@ -214,10 +218,13 @@ def get_language_score(locale):
|
|||||||
)
|
)
|
||||||
except:
|
except:
|
||||||
continue
|
continue
|
||||||
if catalog is None:
|
catalog.update(translation._catalog.copy())
|
||||||
catalog = TranslationCatalog(translation)
|
|
||||||
else:
|
while translation._fallback:
|
||||||
catalog.update(translation)
|
if not locale.startswith(translation._fallback.info().get("language", "XX")):
|
||||||
|
break
|
||||||
|
translation = translation._fallback
|
||||||
|
catalog.update(translation._catalog.copy())
|
||||||
|
|
||||||
if not catalog:
|
if not catalog:
|
||||||
score = 1
|
score = 1
|
||||||
|
|||||||
31464
src/pretix/locale/es_419/LC_MESSAGES/django.po
Normal file
31464
src/pretix/locale/es_419/LC_MESSAGES/django.po
Normal file
File diff suppressed because it is too large
Load Diff
@@ -126,6 +126,7 @@ pre[lang=eg], input[lang=eg], textarea[lang=eg], div[lang=eg] { background-image
|
|||||||
pre[lang=eh], input[lang=eh], textarea[lang=eh], div[lang=eh] { background-image: url(static('pretixbase/img/flags/eh.png')); }
|
pre[lang=eh], input[lang=eh], textarea[lang=eh], div[lang=eh] { background-image: url(static('pretixbase/img/flags/eh.png')); }
|
||||||
pre[lang=er], input[lang=er], textarea[lang=er], div[lang=er] { background-image: url(static('pretixbase/img/flags/er.png')); }
|
pre[lang=er], input[lang=er], textarea[lang=er], div[lang=er] { background-image: url(static('pretixbase/img/flags/er.png')); }
|
||||||
pre[lang=es], input[lang=es], textarea[lang=es], div[lang=es] { background-image: url(static('pretixbase/img/flags/es.png')); }
|
pre[lang=es], input[lang=es], textarea[lang=es], div[lang=es] { background-image: url(static('pretixbase/img/flags/es.png')); }
|
||||||
|
pre[lang=es-419], input[lang=es-419], textarea[lang=es-419], div[lang=es-419] { background-image: url(static('pretixbase/img/flags/es.png')); }
|
||||||
pre[lang=et], input[lang=et], textarea[lang=et], div[lang=et] { background-image: url(static('pretixbase/img/flags/et.png')); }
|
pre[lang=et], input[lang=et], textarea[lang=et], div[lang=et] { background-image: url(static('pretixbase/img/flags/et.png')); }
|
||||||
pre[lang=fi], input[lang=fi], textarea[lang=fi], div[lang=fi] { background-image: url(static('pretixbase/img/flags/fi.png')); }
|
pre[lang=fi], input[lang=fi], textarea[lang=fi], div[lang=fi] { background-image: url(static('pretixbase/img/flags/fi.png')); }
|
||||||
pre[lang=fj], input[lang=fj], textarea[lang=fj], div[lang=fj] { background-image: url(static('pretixbase/img/flags/fj.png')); }
|
pre[lang=fj], input[lang=fj], textarea[lang=fj], div[lang=fj] { background-image: url(static('pretixbase/img/flags/fj.png')); }
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ base_patterns = [
|
|||||||
name='healthcheck'),
|
name='healthcheck'),
|
||||||
re_path(r'^redirect/$', redirect.redir_view, name='redirect'),
|
re_path(r'^redirect/$', redirect.redir_view, name='redirect'),
|
||||||
re_path(r'^site.webmanifest$', webmanifest.webmanifest, name='site.webmanifest'),
|
re_path(r'^site.webmanifest$', webmanifest.webmanifest, name='site.webmanifest'),
|
||||||
re_path(r'^jsi18n/(?P<lang>[a-zA-Z-_]+)/$', js_catalog.js_catalog, name='javascript-catalog'),
|
re_path(r'^jsi18n/(?P<lang>[a-zA-Z0-9_-]+)/$', js_catalog.js_catalog, name='javascript-catalog'),
|
||||||
re_path(r'^metrics$', metrics.serve_metrics,
|
re_path(r'^metrics$', metrics.serve_metrics,
|
||||||
name='metrics'),
|
name='metrics'),
|
||||||
re_path(r'^csp_report/$', csp.csp_report, name='csp.report'),
|
re_path(r'^csp_report/$', csp.csp_report, name='csp.report'),
|
||||||
|
|||||||
Reference in New Issue
Block a user