added langs
This commit is contained in:
parent
dfc3600664
commit
1237e8d045
2 changed files with 64 additions and 4 deletions
59
main.go
59
main.go
|
@ -20,6 +20,61 @@ type SearchResult struct {
|
||||||
Description string
|
Description string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type LanguageOption struct {
|
||||||
|
Code string
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
var languageOptions = []LanguageOption{
|
||||||
|
{Code: "", Name: "Any Language"},
|
||||||
|
{Code: "lang_en", Name: "English"},
|
||||||
|
{Code: "lang_af", Name: "Afrikaans"},
|
||||||
|
{Code: "lang_ar", Name: "العربية (Arabic)"},
|
||||||
|
{Code: "lang_hy", Name: "Հայերեն (Armenian)"},
|
||||||
|
{Code: "lang_be", Name: "Беларуская (Belarusian)"},
|
||||||
|
{Code: "lang_bg", Name: "български (Bulgarian)"},
|
||||||
|
{Code: "lang_ca", Name: "Català (Catalan)"},
|
||||||
|
{Code: "lang_zh-CN", Name: "中文 (简体) (Chinese Simplified)"},
|
||||||
|
{Code: "lang_zh-TW", Name: "中文 (繁體) (Chinese Traditional)"},
|
||||||
|
{Code: "lang_hr", Name: "Hrvatski (Croatian)"},
|
||||||
|
{Code: "lang_cs", Name: "Čeština (Czech)"},
|
||||||
|
{Code: "lang_da", Name: "Dansk (Danish)"},
|
||||||
|
{Code: "lang_nl", Name: "Nederlands (Dutch)"},
|
||||||
|
{Code: "lang_eo", Name: "Esperanto"},
|
||||||
|
{Code: "lang_et", Name: "Eesti (Estonian)"},
|
||||||
|
{Code: "lang_tl", Name: "Filipino (Tagalog)"},
|
||||||
|
{Code: "lang_fi", Name: "Suomi (Finnish)"},
|
||||||
|
{Code: "lang_fr", Name: "Français (French)"},
|
||||||
|
{Code: "lang_de", Name: "Deutsch (German)"},
|
||||||
|
{Code: "lang_el", Name: "Ελληνικά (Greek)"},
|
||||||
|
{Code: "lang_iw", Name: "עברית (Hebrew)"},
|
||||||
|
{Code: "lang_hi", Name: "हिन्दी (Hindi)"},
|
||||||
|
{Code: "lang_hu", Name: "magyar (Hungarian)"},
|
||||||
|
{Code: "lang_is", Name: "íslenska (Icelandic)"},
|
||||||
|
{Code: "lang_id", Name: "Bahasa Indonesia (Indonesian)"},
|
||||||
|
{Code: "lang_it", Name: "italiano (Italian)"},
|
||||||
|
{Code: "lang_ja", Name: "日本語 (Japanese)"},
|
||||||
|
{Code: "lang_ko", Name: "한국어 (Korean)"},
|
||||||
|
{Code: "lang_lv", Name: "latviešu (Latvian)"},
|
||||||
|
{Code: "lang_lt", Name: "lietuvių (Lithuanian)"},
|
||||||
|
{Code: "lang_no", Name: "norsk (Norwegian)"},
|
||||||
|
{Code: "lang_fa", Name: "فارسی (Persian)"},
|
||||||
|
{Code: "lang_pl", Name: "polski (Polish)"},
|
||||||
|
{Code: "lang_pt", Name: "português (Portuguese)"},
|
||||||
|
{Code: "lang_ro", Name: "română (Romanian)"},
|
||||||
|
{Code: "lang_ru", Name: "русский (Russian)"},
|
||||||
|
{Code: "lang_sr", Name: "српски (Serbian)"},
|
||||||
|
{Code: "lang_sk", Name: "slovenčina (Slovak)"},
|
||||||
|
{Code: "lang_sl", Name: "slovenščina (Slovenian)"},
|
||||||
|
{Code: "lang_es", Name: "español (Spanish)"},
|
||||||
|
{Code: "lang_sw", Name: "Kiswahili (Swahili)"},
|
||||||
|
{Code: "lang_sv", Name: "svenska (Swedish)"},
|
||||||
|
{Code: "lang_th", Name: "ไทย (Thai)"},
|
||||||
|
{Code: "lang_tr", Name: "Türkçe (Turkish)"},
|
||||||
|
{Code: "lang_uk", Name: "українська (Ukrainian)"},
|
||||||
|
{Code: "lang_vi", Name: "Tiếng Việt (Vietnamese)"},
|
||||||
|
}
|
||||||
|
|
||||||
var funcs = template.FuncMap{
|
var funcs = template.FuncMap{
|
||||||
"title": func(s string) string {
|
"title": func(s string) string {
|
||||||
return strings.Title(s)
|
return strings.Title(s)
|
||||||
|
@ -148,11 +203,15 @@ func handleSearch(w http.ResponseWriter, r *http.Request) {
|
||||||
Query string
|
Query string
|
||||||
Fetched string
|
Fetched string
|
||||||
ElapsedTime string
|
ElapsedTime string
|
||||||
|
LanguageOptions []LanguageOption
|
||||||
|
CurrentLang string
|
||||||
}{
|
}{
|
||||||
Results: results,
|
Results: results,
|
||||||
Query: query,
|
Query: query,
|
||||||
Fetched: fmt.Sprintf("Fetched the results in %.2f seconds", elapsed.Seconds()),
|
Fetched: fmt.Sprintf("Fetched the results in %.2f seconds", elapsed.Seconds()),
|
||||||
ElapsedTime: strconv.FormatFloat(elapsed.Seconds(), 'f', 2, 64),
|
ElapsedTime: strconv.FormatFloat(elapsed.Seconds(), 'f', 2, 64),
|
||||||
|
LanguageOptions: languageOptions,
|
||||||
|
CurrentLang: lang,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render template
|
// Render template
|
||||||
|
|
|
@ -19,12 +19,13 @@
|
||||||
<form class="results_settings" action="/search" method="get">
|
<form class="results_settings" action="/search" method="get">
|
||||||
<input type="hidden" name="q" value="{{ .Query }}">
|
<input type="hidden" name="q" value="{{ .Query }}">
|
||||||
<select class="results-settings" name="safe" id="safeSearchSelect">
|
<select class="results-settings" name="safe" id="safeSearchSelect">
|
||||||
<option value="active">Safe Search On</option>
|
|
||||||
<option value="">Safe Search Off</option>
|
<option value="">Safe Search Off</option>
|
||||||
|
<option value="active">Safe Search On</option>
|
||||||
</select>
|
</select>
|
||||||
<select class="results-settings" name="lang" id="languageSelect">
|
<select class="results-settings" name="lang" id="languageSelect">
|
||||||
<option value="">Any Language</option>
|
{{range .LanguageOptions}}
|
||||||
<!-- Populate with actual language options as needed -->
|
<option value="{{.Code}}" {{if eq .Code $.CurrentLang}}selected{{end}}>{{.Name}}</option>
|
||||||
|
{{end}}
|
||||||
</select>
|
</select>
|
||||||
<button class="results-save" type="submit">Apply settings</button>
|
<button class="results-save" type="submit">Apply settings</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Add table
Reference in a new issue