Skip to content

Commit

Permalink
version 0.1.1 fertig, Übersetzungen eingebaut mit cookies etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePhisch committed Sep 20, 2020
1 parent e5374d7 commit b506966
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
Binary file modified __pycache__/translate.cpython-35.pyc
Binary file not shown.
13 changes: 11 additions & 2 deletions script.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@

@route("/")
def index():
# return template('transtest')
return template('index')
if b.request.GET.currentLang.strip() != "":
currentLang = str(b.request.GET.currentLang.strip())
b.response.set_cookie('currentLang', currentLang)
elif b.request.get_cookie('currentLang') != "":
currentLang = b.request.get_cookie('currentLang')
else:
if b.request.headers.get('Accept-Language')[:2] == 'en':
currentLang = 'en'
else:
currentLang = 'de'
return template('index', currentLang=currentLang)

@route('/static/<filename>')
def server_static(filename):
Expand Down
10 changes: 8 additions & 2 deletions translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ def getString(self, ID):
except KeyError:
return str(ID)

def setCurrentLang(self, ID):
self.currentLang = self.dic[str(ID)]
def g(self, ID):
return self.getString(ID)

def setLang(self, ID):
try:
self.currentLang = self.dic[str(ID)]
except KeyError:
pass

29 changes: 17 additions & 12 deletions views/index.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<%
import translate
t = translate.Translator()
t.setLang(currentLang)
%>

<html>
<head>
<title>Vorläufige Webseite</title>
Expand All @@ -6,20 +12,17 @@
<body>
<div id="startDiv">
<div class="splits">
<h1>Herrenklo-Simulator</h1>
<!-- <a href="/#startDiv">Start</a>
<a href="/#gameDiv">Spiel</a>
<a href="/#updatesDiv">Updates</a>
<a href="/#impressumDiv">Kontakt</a> -->
<a href="/">Deutsch</a>
<a href="/">English (not active yet)</a>
<h1>{{t.g('TITLE')}}</h1>
<a href="/?currentLang=de">Deutsch</a>
<a href="/?currentLang=en">English</a>
({{t.g('SETS_COOKIE')}})
</div>
<div class="splits rightStart">
<h4>Login (setzt einen Cookie) (derzeit deaktiviert)</h4>
<h4>{{t.g('LOGIN')}} ({{t.g('SETS_COOKIE')}}) ({{t.g('CURR_DEACTIVATED')}})</h4>
<form action="/" method="post">
Username: <input name="username" type="text" />
Passwort: <input name="password" type="password" />
<input value="Login" type="submit" />
{{t.g('USERNAME')}}: <input name="username" type="text" />
{{t.g('PASSWORD')}}: <input name="password" type="password" />
<input value="{{t.g('LOGIN')}}" type="submit" />
</form>
</div>
</div>
Expand All @@ -35,12 +38,14 @@
<li>16.09.2020 0.3.1</li>
<li>17.09.2020 0.3.1-webpatch1; kleine Änderungen, die auf erste Kommentare/Kritiken eingehen</li>
<li>20.09.2020 Updated Server to 0.1</li>
<li>20.09.2020 Updated Server to 0.1.1</li>
</ol>
</div>
<div id="impressumDiv">
<h4>Impressum/Kontakt</h4>
Ohne Impressum, da private Webseite. Ich schalte keine Werbung, verkaufe nix und biete keine
journalistischen Inhalte an. Kontaktaufnahme erstmal über urinalgame (at) gmail (dot) com.
journalistischen Inhalte an. Standardmäßig werden keine Cookies gesetzt. Überall dort, wo Cookies
gesetzt werden, wird darauf hingewiesen. Kontaktaufnahme erstmal über urinalgame (at) gmail (dot) com.
</div>
</body>
</html>

0 comments on commit b506966

Please sign in to comment.