mirror of
https://codeberg.org/aryak/mozhi
synced 2024-12-21 21:39:48 +05:30
add support for transliteration
This commit is contained in:
parent
709e7c5ab9
commit
b8c7be7a96
2
go.mod
2
go.mod
@ -7,7 +7,7 @@ replace github.com/OwO-Network/gdeeplx => github.com/gi-yt/gdeeplx v0.0.0-202308
|
||||
//replace codeberg.org/aryak/libmozhi => /home/arya/projects/mozhi/libmozhi
|
||||
|
||||
require (
|
||||
codeberg.org/aryak/libmozhi v0.0.0-20231129140947-7c9580a1ea2d
|
||||
codeberg.org/aryak/libmozhi v0.0.0-20231129152229-c0d8dfbccd68
|
||||
github.com/gofiber/fiber/v2 v2.51.0
|
||||
github.com/gofiber/swagger v0.1.14
|
||||
github.com/gofiber/template v1.8.0
|
||||
|
2
go.sum
2
go.sum
@ -51,6 +51,8 @@ codeberg.org/aryak/libmozhi v0.0.0-20231129121457-7f83a4201d39 h1:XmDg0Fm0WL8xGD
|
||||
codeberg.org/aryak/libmozhi v0.0.0-20231129121457-7f83a4201d39/go.mod h1:Ohfzqv/+t2t350TFNlHNBIXc42lOdv+3MkBtozYxMUY=
|
||||
codeberg.org/aryak/libmozhi v0.0.0-20231129140947-7c9580a1ea2d h1:CxJsKo6EHksw6yBWX02uDnNntbszkybgPuN0PzGyBNA=
|
||||
codeberg.org/aryak/libmozhi v0.0.0-20231129140947-7c9580a1ea2d/go.mod h1:Ohfzqv/+t2t350TFNlHNBIXc42lOdv+3MkBtozYxMUY=
|
||||
codeberg.org/aryak/libmozhi v0.0.0-20231129152229-c0d8dfbccd68 h1:Pwsv6oLj51GhlcrlBIPc91jliNeJx6sPdPKYnzhZqMg=
|
||||
codeberg.org/aryak/libmozhi v0.0.0-20231129152229-c0d8dfbccd68/go.mod h1:Ohfzqv/+t2t350TFNlHNBIXc42lOdv+3MkBtozYxMUY=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
|
@ -2,6 +2,7 @@ package serve
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"strings"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -37,9 +38,8 @@ func Serve(port string) {
|
||||
engine := html.NewFileSystem(views, ".html")
|
||||
|
||||
engine.AddFunc(
|
||||
// Add unescape function. This is needed to render HTML from Markdown.
|
||||
"unescape", func(s string) template.HTML {
|
||||
return template.HTML(s)
|
||||
"newlinetobr", func(s string) template.HTML {
|
||||
return template.HTML(strings.ReplaceAll(strings.ReplaceAll(s, "\n", "<br>"), "\r", ""))
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
<!-- This hidden input is so that the engine gets sent in the request even though its not declared here -->
|
||||
<input name="engine" value="{{.Engine}}" type="hidden" />
|
||||
|
||||
<div class="wrap languages center-area" >
|
||||
<div class="wrap languages center-area">
|
||||
<div class="language">
|
||||
<select name="from" aria-label="Source language" id="sourceLanguage">
|
||||
{{range $key, $value := .SourceLanguages}} {{if $.From}}
|
||||
@ -64,10 +64,12 @@
|
||||
<textarea autofocus class="item" id="input" name="text" dir="auto" placeholder="Enter Text Here">
|
||||
{{ .OriginalText }}</textarea>
|
||||
{{if .TtsFrom}}
|
||||
<br>
|
||||
<audio controls>
|
||||
<source type="audio/mpeg" src="{{ .TtsFrom }}" />
|
||||
</audio>
|
||||
{{end}}
|
||||
<br>
|
||||
</div>
|
||||
|
||||
{{ if .TranslateAll }}
|
||||
@ -77,11 +79,16 @@
|
||||
<textarea class="translation item" dir="auto" placeholder="Translation" id="output" readonly>
|
||||
{{.OutputText}}</textarea>
|
||||
{{if .AutoDetect}}
|
||||
Detected Language: {{.AutoDetect}}{{end}} {{if $.TtsTo}}
|
||||
<br>Detected Language: {{.AutoDetect}}{{end}}
|
||||
{{if .Translation.Transliteration}}
|
||||
<br>Transliteration: {{newlinetobr .Translation.Transliteration}}{{end}}
|
||||
{{if $.TtsTo}}
|
||||
<br>
|
||||
<audio controls>
|
||||
<source type="audio/mpeg" src="{{ $.TtsTo }}" />
|
||||
</audio>
|
||||
{{end}}
|
||||
<br>
|
||||
</div>
|
||||
{{end}}
|
||||
{{ else }} {{if .TranslationExists}}
|
||||
@ -89,11 +96,16 @@
|
||||
<textarea class="translation item" dir="auto" placeholder="Translation" id="output" readonly>
|
||||
{{.Translation.OutputText}}</textarea>
|
||||
{{if .Translation.AutoDetect}}
|
||||
Detected Language: {{.Translation.AutoDetect}}{{end}} {{if .TtsTo}}
|
||||
<br>Detected Language: {{.Translation.AutoDetect}}{{end}}
|
||||
{{if .Translation.Transliteration}}
|
||||
<br>Transliteration: {{newlinetobr .Translation.Transliteration}}{{end}}
|
||||
{{if .TtsTo}}
|
||||
<br>
|
||||
<audio controls>
|
||||
<source type="audio/mpeg" src="{{ .TtsTo }}" />
|
||||
</audio>
|
||||
{{end}}
|
||||
<br>
|
||||
{{end}}
|
||||
{{end}}
|
||||
<div style="display:flex; justify-content:space-around; align-items:center;">
|
||||
@ -102,7 +114,9 @@
|
||||
Copy the translation
|
||||
</button>
|
||||
{{end}}
|
||||
{{ if and .Engine .From .To .OriginalText }}<p><a class="button" style="color:#010000; text-decoration: none;" href="/?engine={{.Engine}}&from={{.From}}&to={{.To}}&text={{.OriginalText}}">Copy translation link</a></p>{{end}}
|
||||
{{ if and .Engine .From .To .OriginalText }}<p><a class="button" style="color:#010000; text-decoration: none;"
|
||||
href="/?engine={{.Engine}}&from={{.From}}&to={{.To}}&text={{.OriginalText}}">Copy translation link</a></p>
|
||||
{{end}}
|
||||
{{if .TranslationExists}}
|
||||
<button class="wrap" type="submit">
|
||||
{{else}}
|
||||
|
Loading…
Reference in New Issue
Block a user