Fixed a bug

git-svn-id: file:///srv/svn/repo/mai/trunk@32 e410bdd4-646f-c54f-a7ce-fffcc4f439ae
This commit is contained in:
manerakai 2023-09-20 11:59:10 +00:00
parent 5182de046a
commit 0f7330e9da
2 changed files with 14 additions and 3 deletions

View File

@ -277,6 +277,10 @@ func (_ *GoogleTranslate) Translate(text string, from, to string) (TranslationRe
} }
} }
if from == "auto" {
from = ""
}
return TranslationResult{ return TranslationResult{
SourceLanguage: from, SourceLanguage: from,
Definitions: definitions, Definitions: definitions,

View File

@ -35,7 +35,8 @@
<select name="from" aria-label="Source language"> <select name="from" aria-label="Source language">
{{range $code, $name := .SourceLanguages}} {{range $code, $name := .SourceLanguages}}
{{if and (eq $code "auto") $.SourceLanguage}} {{if and (eq $code "auto") $.SourceLanguage}}
<option value="{{ $code }}" {{if eq $code $.From}}selected{{end}}>{{ $name }} ({{index $.SourceLanguages $.SourceLanguage}})</option> <option value="{{ $code }}" {{if eq $code $.From}}selected{{end}}>{{ $name }} ({{index
$.SourceLanguages $.SourceLanguage}})</option>
{{else }} {{else }}
<option value="{{ $code }}" {{if eq $code $.From}}selected{{end}}>{{ $name }}</option> <option value="{{ $code }}" {{if eq $code $.From}}selected{{end}}>{{ $name }}</option>
{{end}} {{end}}
@ -126,7 +127,8 @@
{{ range $word, $word_translations := $translations }} {{ range $word, $word_translations := $translations }}
<li> <li>
<span class="syn_type">{{$word}}:</span> <span class="syn_type">{{$word}}:</span>
<span class="syn">{{ range $index, $element := $word_translations.words}}{{if $index}}, {{end}}{{$element}}{{end}}</span> <span class="syn">{{ range $index, $element := $word_translations.words}}{{if $index}},
{{end}}{{$element}}{{end}}</span>
<span class="syn_type">{{$word_translations.frequency}}</span> <span class="syn_type">{{$word_translations.frequency}}</span>
</li> </li>
<br> <br>
@ -138,6 +140,11 @@
</div> </div>
</form> </form>
<br><br><br><br><br>
<footer class="center">
<a href="https://codeberg.org/ManeraKai/simplytranslate">Source Code</a>
</footer>
<script src="/static/script.js"></script> <script src="/static/script.js"></script>
</body> </body>