Language in progress

This commit is contained in:
Claude Brisson
2023-06-12 20:25:21 +02:00
parent 82bb0115ae
commit cc0e42eb5a
4 changed files with 35 additions and 9 deletions

View File

@@ -3,13 +3,23 @@ package org.jeudego.pairgoth.view
import org.apache.velocity.tools.config.ValidScope
import org.jeudego.pairgoth.util.Translator
@ValidScope("request")
@ValidScope("application")
class TranslationTool {
fun translate(enText: String): String {
return translator.get().translate(enText)
}
val languages = Translator.providedLanguages
val flags = Translator.providedLanguages.associate { iso ->
when (iso) {
"en" -> "gb uk"
"zh" -> "cn"
else -> iso
}.let { Pair(iso, it) }
}
companion object {
val translator = ThreadLocal<Translator>()
}

View File

@@ -2,11 +2,12 @@
@layer pairgoth {
body {
font-size : clamp(1rem, 3vw, 3rem);
font-size : clamp(1rem, 2vw, 3rem);
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
overflow: hidden;
}
.flex {
@@ -22,13 +23,18 @@
}
#header {
height: 2em;
height: 3em;
width: 100%;
position: relative;
justify-content: space-between;
#left-header, #right-header {
#left-header {
height: 100%;
}
#right-header {
height: 100%;
margin-top: 0.5em;
margin-right: 0.5em;
}
#logo {
height: 100%;
img {
@@ -40,15 +46,19 @@
#center {
max-width: clamp(800px, 80vw, 100vw);
margin-left: auto;
margin-right: auto;
flex: 1;
overflow: auto;
#inner {
display: flex;
flex-flow: column nowrap;
align-items: center;
}
}
#footer {
flex: 0;
height: 2em;
margin: 0 2em;
margin: 0 0.5em;
font-size: 0.8em;
justify-content: space-between;
}
@@ -57,6 +67,10 @@
padding: 0.5em;
}
button {
font-size: inherit;
}
button.floating {
box-shadow: 0px 8px 8px -5px rgba(0,0,0,35%);
transition: all 0.3s;

View File

@@ -17,12 +17,14 @@
</div>
</div>
<div id="right-header">
[flag]
<i class="$translate.flags[$request.lang] flag"></i>
</div>
</div>
<div id="center">
<div id="inner">
#translate($page)
</div>
</div>
<div id="footer" class="horz flex">
<div id="version">pairgoth v0.1</div>
<div id="contact"><a href="mailto:pairgoth@jeudego.org">contact</a></div>

View File

@@ -2,6 +2,7 @@
<tools xmlns:xi="http://www.w3.org/2001/XInclude">
<toolbox scope="application">
<tool key="translate" class="org.jeudego.pairgoth.view.TranslationTool"/>
<!--
<tool key="number" format="#0.00"/>
<tool key="date" locale="fr_FR" format="yyyy-MM-dd"/>
@@ -17,7 +18,6 @@
</toolbox>
<toolbox scope="request">
<tool key="translate" class="org.jeudego.pairgoth.view.TranslationTool"/>
<tool key="api" class="org.jeudego.pairgoth.view.ApiTool"/>
</toolbox>