Skip to content

Commit 44b0992

Browse files
committed
WIP
1 parent 82ee506 commit 44b0992

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2595
-1424
lines changed

.tx/config

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[main]
2+
host = https://www.transifex.com
3+
4+
[CC.django-po]
5+
file_filter = locale/<lang>/LC_MESSAGES/django.po
6+
minimum_perc = 0
7+
source_file = locale/en/LC_MESSAGES/django.po
8+
source_lang = en
9+
type = PO
10+

Makefile

+2-3
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ production-deploy-key: conf/keys/production.pub.ssh
4343
# Translation helpers
4444
makemessages:
4545
# Extract English messages from our source code
46-
python manage.py makemessages --ignore 'conf/*' --ignore 'docs/*' --ignore 'requirements/*' \
47-
--no-location --no-obsolete -l en
46+
python manage.py makemessages
4847

49-
compilemessages:
48+
compile_messages:
5049
# Compile PO files into the MO files that Django will use at runtime
5150
python manage.py compilemessages
5251

babel_mapping.ini

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# http://babel.pocoo.org/en/latest/messages.html#extraction-method-mapping-and-configuration
2+
3+
[extractors]
4+
django = enmerkar.extract:extract_django
5+
6+
# Extraction from Python source files
7+
[python: **.py]
8+
9+
# Extraction from Django template files
10+
[django: **/templates/**.html]

cc_licenses/settings/base.py

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"django.contrib.messages",
2929
"django.contrib.staticfiles",
3030

31+
'deeds',
3132
'licenses',
3233
]
3334

@@ -193,3 +194,6 @@
193194
SECURE_BROWSER_XSS_FILTER = True
194195
CSRF_COOKIE_HTTPONLY = True
195196
X_FRAME_OPTIONS = 'DENY'
197+
198+
# Percent translated that languages should be at or above
199+
TRANSLATION_THRESHOLD = 80

cc_licenses/settings/dev.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
DEBUG = True
88

9-
INSTALLED_APPS += (
9+
INSTALLED_APPS += [
1010
'debug_toolbar',
11-
)
11+
]
1212
MIDDLEWARE += (
1313
'debug_toolbar.middleware.DebugToolbarMiddleware',
1414
)
@@ -34,3 +34,6 @@
3434
)
3535

3636
LOGGING['root']['handlers'] = []
37+
38+
# Make it obvious if there are unresolved variables in templates
39+
TEMPLATES[0]['OPTIONS']['string_if_invalid'] = "INVALID_VARIABLE(%s)"

cc_licenses/templates/404.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% extends "base.html" %}
22

3-
{% block title %}Page Not Found :({% endblock %}
3+
{% block title %}{% blocktrans %}Page Not Found{% endblocktrans %} :({% endblock %}
44

55
{% block content %}
66
<h1>Not found <span>:(</span></h1>

deeds/locale_negotiation.py

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Locale negotiation tools
2+
import os
3+
4+
5+
CACHED_APPLICABLE_LANGS = {}
6+
MO_PATH = "FIXME SET MO_PATH OR DO NOT USE"
7+
8+
9+
def negotiate_locale(locale, mo_path=MO_PATH):
10+
"""
11+
Choose the appropriate locale, using fallbacks, given the
12+
'requested' locale.
13+
14+
Actually just a wrapper function for applicable_langs().
15+
"""
16+
return applicable_langs(locale, mo_path)[0]
17+
18+
19+
def applicable_langs(locale, mo_path=MO_PATH):
20+
"""
21+
Return all available languages "applicable" to a requested locale.
22+
"""
23+
cache_key = (locale, mo_path)
24+
if cache_key in CACHED_APPLICABLE_LANGS:
25+
return CACHED_APPLICABLE_LANGS[cache_key]
26+
27+
applicable_langs = []
28+
if os.path.exists(os.path.join(mo_path, locale)):
29+
applicable_langs.append(locale)
30+
31+
if '_' in locale:
32+
root_lang = locale.split('_')[0]
33+
if os.path.exists(os.path.join(mo_path, root_lang)):
34+
applicable_langs.append(root_lang)
35+
36+
if not 'en' in applicable_langs:
37+
applicable_langs.append('en')
38+
39+
# Don't cache silly languages that only fallback to en anyway, to
40+
# (semi-)prevent caching infinite amounts of BS
41+
if not locale == 'en' and len(applicable_langs) == 1:
42+
return applicable_langs
43+
44+
CACHED_APPLICABLE_LANGS[cache_key] = applicable_langs
45+
return applicable_langs

deeds/mappers.py

+207
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
_ = lambda s: s
2+
3+
4+
COUNTRY_MAP = {
5+
"ar": _("Argentina"),
6+
"at": _("Austria"),
7+
"au": _("Australia"),
8+
"be": _("Belgium"),
9+
"bg": _("Bulgaria"),
10+
"br": _("Brazil"),
11+
"ca": _("Canada"),
12+
"ch": _("Switzerland"),
13+
"cl": _("Chile"),
14+
"cn": _("China Mainland"),
15+
"co": _("Colombia"),
16+
"cr": _("Costa Rica"),
17+
"cz": _("Czech Republic"),
18+
"de": _("Germany"),
19+
"dk": _("Denmark"),
20+
"ec": _("Ecuador"),
21+
"ee": _("Estonia"),
22+
"eg": _("Egypt"),
23+
"es": _("Spain"),
24+
"es-ca": _("Catalonia"),
25+
"fi": _("Finland"),
26+
"fr": _("France"),
27+
"gr": _("Greece"),
28+
"gt": _("Guatemala"),
29+
"hk": _("Hong Kong"),
30+
"hr": _("Croatia"),
31+
"hu": _("Hungary"),
32+
"ie": _("Ireland"),
33+
"il": _("Israel"),
34+
"igo": _("IGO"),
35+
"in": _("India"),
36+
"it": _("Italy"),
37+
"jo": _("Jordan"),
38+
"jp": _("Japan"),
39+
"kr": _("South Korea"),
40+
"lu": _("Luxembourg"),
41+
"mk": _("Macedonia"),
42+
"mt": _("Malta"),
43+
"mx": _("Mexico"),
44+
"my": _("Malaysia"),
45+
"ng": _("Nigeria"),
46+
"nl": _("Netherlands"),
47+
"no": _("Norway"),
48+
"nz": _("New Zealand"),
49+
"pe": _("Peru"),
50+
"ph": _("Philippines"),
51+
"pl": _("Poland"),
52+
"pr": _("Puerto Rico"),
53+
"pt": _("Portugal"),
54+
"ro": _("Romania"),
55+
"rs": _("Serbia"),
56+
"scotland": _("UK: Scotland"),
57+
"se": _("Sweden"),
58+
"sg": _("Singapore"),
59+
"si": _("Slovenia"),
60+
"sk": _("Slovak Republic"),
61+
"th": _("Thailand"),
62+
"tw": _("Taiwan"),
63+
"ua": _("Ukraine"),
64+
"ug": _("Uganda"),
65+
"uk": _("UK: England & Wales"),
66+
"us": _("United States"),
67+
"ve": _("Venezuela"),
68+
"vn": _("Vietnam"),
69+
"za": _("South Africa")}
70+
71+
72+
LANG_MAP = {
73+
"af": _("Afrikaans"),
74+
"ar": _("Arabic"),
75+
"as": _("Assamese"),
76+
"ast": _("Asturian"),
77+
"az": _("Azerbaijani"),
78+
"be": _("Belarusian"),
79+
"bg": _("Bulgarian"),
80+
"bn": _("Bengali"),
81+
"ca": _("Catalan"),
82+
"cs": _("Czech"),
83+
"da": _("Danish"),
84+
"de": _("German"),
85+
"el": _("Greek"),
86+
"en": _("English"),
87+
"en_CA": _("English (CA)"),
88+
"en_GB": _("English (GB)"),
89+
"en_HK": _("English (Hong Kong)"),
90+
"en_SG": _("English (Singapore)"),
91+
"en_US": _("English (US)"),
92+
"eo": _("Esperanto"),
93+
"es": _("Spanish"),
94+
"es_AR": _("Spanish (AR)"),
95+
"es_CL": _("Spanish (CL)"),
96+
"es_CO": _("Spanish (CO)"),
97+
"es_EC": _("Spanish (Ecuador)"),
98+
"es_ES": _("Spanish (Spain)"),
99+
"es_GT": _("Spanish (Guatemala)"),
100+
"es_MX": _("Spanish (MX)"),
101+
"es_PE": _("Spanish (PE)"),
102+
"et": _("Estonian"),
103+
"eu": _("Basque"),
104+
"fa": _("Persian"),
105+
"fi": _("Finnish"),
106+
"fr": _("French"),
107+
"fr_CA": _("French (CA)"),
108+
"ga": _("Irish"),
109+
"gl": _("Galician"),
110+
"he": _("Hebrew"),
111+
"hi": _("Hindi"),
112+
"hr": _("Croatian"),
113+
"hu": _("Hungarian"),
114+
"hy": _("Armenian"),
115+
"id": _("Indonesian"),
116+
"is": _("Icelandic"),
117+
"it": _("Italian"),
118+
"ja": _("Japanese"),
119+
"ka": _("Georgian"),
120+
"kk": _("Kazakh"),
121+
"ko": _("Korean"),
122+
"lt": _("Lithuanian"),
123+
"lv": _("Latvian"),
124+
"mk": _("Macedonian"),
125+
"ml": _("Malayalam"),
126+
"mn": _("Mongolian"),
127+
"ms": _("Malay"),
128+
"nl": _("Dutch"),
129+
"no": _("Norwegian"),
130+
"nso": _("Northern Sotho"),
131+
"oci_ES": _("Aranese"),
132+
"pl": _("Polish"),
133+
"pt": _("Portuguese"),
134+
"pt_BR": _("Portuguese (BR)"),
135+
#"pt_PT": _("Portuguese (Portugal)"),
136+
"ro": _("Romanian"),
137+
"ru": _("Russian"),
138+
"si_LK": _("Sinhala"),
139+
"sl": _("Slovenian"),
140+
"sr": _("Serbian"),
141+
"sr_LATN": _("Serbian (Latin)"),
142+
"st": _("Sotho"),
143+
"sv": _("Swedish"),
144+
"ta": _("Tamil"),
145+
"te": _("Telugu"),
146+
"th": _("Thai"),
147+
"tr": _("Turkish"),
148+
"uk": _("Ukranian"),
149+
"ur": _("Urdu"),
150+
"vi": _("Vietnamese"),
151+
"zh": _("Chinese"),
152+
"zh_CN": _("Chinese"),
153+
"zh_HK": _("Chinese (Hong Kong)"),
154+
"zh_TW": _("Chinese (Taiwan)"),
155+
"zu": _("Zulu")}
156+
157+
158+
LICENSE_NAME_MAP = {
159+
"GPL": _("GPL"),
160+
"LGPL": _("LGPL"),
161+
"by": _("Attribution"),
162+
"by-nc": _("Attribution-NonCommercial"),
163+
"by-nc-nd": _("Attribution-NonCommercial-NoDerivs"),
164+
"by-nc-sa": _("Attribution-NonCommercial-ShareAlike"),
165+
"by-nd": _("Attribution-NoDerivs"),
166+
"by-nd-nc": _("Attribution-NoDerivs-NonCommercial"),
167+
"by-sa": _("Attribution-ShareAlike"),
168+
"mark": _("Public Domain Mark"),
169+
"nc": _("NonCommercial"),
170+
"nc-sa": _("NonCommercial-ShareAlike"),
171+
"nc-sampling+": _("NonCommercial Sampling Plus"),
172+
"nd": _("NoDerivs"),
173+
"nd-nc": _("NoDerivs-NonCommercial"),
174+
"publicdomain": _("Public Domain"),
175+
"sa": _("ShareAlike"),
176+
"sampling": _("Sampling"),
177+
"sampling+": _("Sampling Plus")}
178+
179+
180+
CHARACTERISTIC_TITLE_MAP = {
181+
"by": _("Attribution"),
182+
"nc": _("Noncommercial"),
183+
"nd": _("No Derivative Works"),
184+
"sa": _("Share Alike")}
185+
186+
187+
CHARACTERISTIC_BRIEF_DESC_MAP = {
188+
"by": _(
189+
"You must attribute the work in the manner specified by the author "
190+
"or licensor (but not in any way that suggests that they endorse you "
191+
"or your use of the work)."),
192+
"na": _(
193+
"You may not use this work to advertise for or promote anything but "
194+
"the work you create from it."),
195+
"nc": _("You may not use this work for commercial purposes."),
196+
"nd": _("You may not alter, transform, or build upon this work."),
197+
"no": _(
198+
"You may not perform, display, or distribute copies of this whole "
199+
"work for any purpose."),
200+
"sa": _(
201+
"If you alter, transform, or build upon this work, you may "
202+
"distribute the resulting work only under the same or similar "
203+
"license to this one."),
204+
"sa_bysa30": _(
205+
"If you alter, transform, or build upon this work, you may "
206+
"distribute the resulting work only under the same, similar "
207+
"or a compatible license.")}

0 commit comments

Comments
 (0)