add support for yandex alternative words and synonyms

This commit is contained in:
2024-05-22 17:36:52 +05:30
parent 555567ccdb
commit 35191f6ca9
5 changed files with 114 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
{{template "header" .}}
{{ template "header" . }}
<main>
<h1>About Mozhi</h1>
<h2>What is Mozhi?</h2>
@@ -6,10 +6,7 @@
Mozhi is an alternative frontend for many translation engines such as
google, yandex, duckduckgo, libretranslate and more!
</p>
<h2>
Why would I use this over just directly accessing the engine in question
</h2>
<h2>Why would I use this over just directly accessing the engine in question</h2>
<p>
There are many reasons why using an alternative-frontend like mozhi is
superior to directly accessing the service in question, and the biggest and
@@ -23,4 +20,4 @@
the engines right in front of you is extremely useful.
</p>
</main>
{{ template "footer" .}}
{{ template "footer" . }}

View File

@@ -140,6 +140,9 @@
{{ end }}
</div>
</div>
{{ if eq .Engine "yandex" }}
{{ template "yandex_extras" . }}
{{ end }}
</form>
<script>
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0

42
views/yandex_extras.html Normal file
View File

@@ -0,0 +1,42 @@
{{ if .Translation.WordChoices }}
<div id="definitions_and_translations">
<div class="translations">
{{ if or .Translation.TargetSynonyms .Translation.SourceSynonyms }}
<span class="def_type">Synonyms</span>
<ul>
{{ if .Translation.TargetSynonyms }}
<li>
<span class="syn_type">{{.Translation.OutputText}}</span>
<span class="syn">{{ range $index, $key := .Translation.TargetSynonyms }}{{ if eq $key "" }}{{ else }}{{ if eq $index 0 }}{{ else }}, {{ end }}{{.}}{{ end }}{{ end }}</span>
</li>
<br>
{{ end }}
{{ if .Translation.SourceSynonyms }}
<li>
<span class="syn_type">{{.OriginalText}}</span>
<span class="syn">{{ range $index, $key := .Translation.SourceSynonyms }}{{ if eq $key "" }}{{ else }}{{ if eq $index 0 }}{{ else }}, {{ end }}{{.}}{{ end }}{{ end }}</span>
</li>
<br>
{{ end }}
</ul>
{{ end }}
</div>
<div class="definitions">
{{ range $key := .Translation.WordChoices }}
<span class="def_type">{{ $key.Word }}</span>
<ol>
{{ range $index, $key2 := $key.ExamplesSource }}
<li>
say or shout “hello”; greet someone.
<br>
<span class="use_in_sentence">{{ index $key.ExamplesSource $index }}</span>
<br>
<span class="use_in_sentence">{{ index $key.ExamplesTarget $index }}</span>
<br>
</li>
{{ end }}
</ol>
{{ end }}
</div>
</div>
{{ end }}