add google alt. words support
All checks were successful
mozhi pipeline / Push Docker image to Codeberg docker registry (push) Successful in 16m41s
mozhi pipeline / Build and publish artifacts (push) Successful in 42m3s

This commit is contained in:
2024-05-27 15:42:20 +05:30
parent 098bd9f577
commit bf61d39f12
4 changed files with 103 additions and 58 deletions

54
views/google_extras.html Normal file
View File

@@ -0,0 +1,54 @@
{{ if .Translation.WordChoices }}
<div id="definitions_and_translations">
<div class="translations">
{{ if or .Translation.TargetSynonyms .Translation.SourceSynonyms .Translation.SourceEquivalentTargetLang .Translation.TargetEquivalentSourceLang }}
<span class="def_type">Synonyms &amp; Equivalent Words</span>
<ul>
{{ if .Translation.TargetSynonyms }}
<li>
<span class="syn_type">Synonyms for {{.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">Synonyms for {{.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 }}
{{ if .Translation.SourceEquivalentTargetLang}}
{{ range $key, $val := .Translation.SourceEquivalentTargetLang }}
<li>
<span class="syn_type">Equivalents for {{$key}}</span>
<span class="syn">{{ range $index, $key2 := $val}}{{ if eq $key2 "" }}{{ else }}{{ if eq $index 0 }}{{ else }}, {{ end }}{{.}}{{ end }}{{ end }}</span>
</li>
<br>
{{ end }}
{{ end }}
{{ if .Translation.TargetEquivalentSourceLang}}
{{ range $key, $val := .Translation.TargetEquivalentSourceLang }}
<li>
<span class="syn_type">Equivalents for {{$key}}</span>
<span class="syn">{{ range $index, $key2 := $val}}{{ if eq $key2 "" }}{{ else }}{{ if eq $index 0 }}{{ else }}, {{ end }}{{.}}{{ end }}{{ end }}</span>
</li>
<br>
{{ end }}
{{ end }}
</ul>
{{ end }}
</div>
<div class="definitions">
{{ range $key := .Translation.WordChoices }}
<span class="def_type">{{ $key.Word }}</span>
<ol>
<li>{{ $key.Definition }}
<br>
<span class="use_in_sentence">{{ .Example }}</span>
</li>
</ol>
{{ end }}
</div>
</div>
{{ end }}

View File

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