-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathheader.py
More file actions
101 lines (91 loc) · 2.77 KB
/
header.py
File metadata and controls
101 lines (91 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# -*- coding: utf-8 -*-
from browser import document as doc
from browser.html import *
trans_menu = {
'menu_console': {
'en': 'Console',
'es': 'Consola',
'fr': 'Console',
'pt': 'Console'},
'menu_editor': {
'en': 'Editor',
'es': 'Editor',
'fr': 'Editeur',
'pt': 'Editor'},
'menu_gallery': {
'en': 'Gallery',
'es': 'Galería',
'fr': 'Galerie',
'pt': 'Galeria'},
'menu_doc': {
'en': 'Documentation',
'es': 'Documentación',
'fr': 'Documentation',
'pt': 'Documentação'},
'menu_download': {
'en': 'Download',
'es': 'Descargas',
'fr': 'Téléchargement',
'pt': 'Download'},
'menu_dev': {
'en': 'Development',
'es': 'Desarrollo',
'fr': 'Développement',
'pt': 'Desenvolvimento'},
'menu_groups': {
'en': 'Groups',
'es': 'Grupos',
'fr': 'Groupes',
'pt': 'Grupos'}
}
links = {'home': 'index.html',
'console': 'tests/console.html',
'editor': 'tests/editor.html',
'gallery': 'gallery/gallery_%s.html',
'doc': 'doc/%s/index.html',
'download': 'https://github.com/brython-dev/brython/releases',
'dev': 'https://github.com/brython-dev/brython',
'groups': 'groups.html'
}
def show(prefix=''):
# detect language
language = "en" # default
has_req = False
qs_lang = doc.query.getfirst("lang")
if qs_lang and qs_lang in ["en", "fr", "es"]:
has_req = True
language = qs_lang
else:
import locale
try:
lang, enc = locale.getdefaultlocale()
lang = lang[:2]
if lang in ("en", "fr", "es"):
language = lang
except:
pass
#_banner = doc['banner_row']
for key in['home', 'console', 'editor', 'gallery',
'doc', 'download', 'dev', 'groups']:
if key in ('download', 'dev'):
href = links[key]
else:
href = prefix + links[key]
if key in ('doc', 'gallery'):
href = href % language
if has_req and key not in ('download', 'dev'):
# add lang to href
href += '?lang=%s' % language
if key == 'home':
img = IMG(src=prefix + "brython_white.png", Class="logo",
alt="Brython Logo", title="Brython")
link = A(img, href=href)
cell = TD(link, Class="logo")
else:
link = A(trans_menu['menu_%s' % key][language],
href=href, Class="banner")
cell = TD(link)
if key in ('download', 'dev'):
link.target = "_blank"
#_banner <= cell
return qs_lang, language