mirror of
https://github.com/Theodor-Springmann-Stiftung/musenalm.git
synced 2026-02-04 02:25:30 +00:00
BUGFIX: mor langauages in almach view
This commit is contained in:
@@ -34,10 +34,27 @@ func SearchPlaces(app core.App, term string, limit int) ([]*Place, error) {
|
||||
Limit(int64(limit))
|
||||
|
||||
if trimmed != "" {
|
||||
query = query.Where(dbx.Or(
|
||||
dbx.Like(PLACES_NAME_FIELD, trimmed).Match(true, true),
|
||||
dbx.Like(PLACES_PSEUDONYMS_FIELD, trimmed).Match(true, true),
|
||||
))
|
||||
terms := []string{trimmed}
|
||||
if strings.Contains(trimmed, "/") {
|
||||
normalized := strings.ReplaceAll(trimmed, "/", " ")
|
||||
normalized = strings.Join(strings.Fields(normalized), " ")
|
||||
collapsed := strings.ReplaceAll(trimmed, "/", "")
|
||||
if normalized != "" && normalized != trimmed {
|
||||
terms = append(terms, normalized)
|
||||
}
|
||||
if collapsed != "" && collapsed != trimmed && collapsed != normalized {
|
||||
terms = append(terms, collapsed)
|
||||
}
|
||||
}
|
||||
|
||||
conditions := make([]dbx.Expression, 0, len(terms)*2)
|
||||
for _, term := range terms {
|
||||
conditions = append(conditions,
|
||||
dbx.Like(PLACES_NAME_FIELD, term).Match(true, true),
|
||||
dbx.Like(PLACES_PSEUDONYMS_FIELD, term).Match(true, true),
|
||||
)
|
||||
}
|
||||
query = query.Where(dbx.Or(conditions...))
|
||||
}
|
||||
|
||||
if err := query.All(&places); err != nil {
|
||||
|
||||
102
helpers/functions/language.go
Normal file
102
helpers/functions/language.go
Normal file
@@ -0,0 +1,102 @@
|
||||
package functions
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"golang.org/x/text/language"
|
||||
"golang.org/x/text/language/display"
|
||||
)
|
||||
|
||||
var languageAliases = map[string]string{
|
||||
"ger": "de",
|
||||
"deu": "de",
|
||||
"fre": "fr",
|
||||
"fra": "fr",
|
||||
"eng": "en",
|
||||
"ita": "it",
|
||||
"lat": "la",
|
||||
"dut": "nl",
|
||||
"nld": "nl",
|
||||
"spa": "es",
|
||||
"por": "pt",
|
||||
"rus": "ru",
|
||||
"pol": "pl",
|
||||
"cze": "cs",
|
||||
"ces": "cs",
|
||||
"slo": "sk",
|
||||
"slk": "sk",
|
||||
"gre": "el",
|
||||
"ell": "el",
|
||||
"arm": "hy",
|
||||
"hye": "hy",
|
||||
"baq": "eu",
|
||||
"eus": "eu",
|
||||
"ice": "is",
|
||||
"isl": "is",
|
||||
"rum": "ro",
|
||||
"ron": "ro",
|
||||
"chi": "zh",
|
||||
"zho": "zh",
|
||||
"jpn": "ja",
|
||||
"kor": "ko",
|
||||
"tur": "tr",
|
||||
"ara": "ar",
|
||||
"heb": "he",
|
||||
"ukr": "uk",
|
||||
"swe": "sv",
|
||||
"dan": "da",
|
||||
"nor": "no",
|
||||
"fin": "fi",
|
||||
"hun": "hu",
|
||||
"lit": "lt",
|
||||
"lav": "lv",
|
||||
"est": "et",
|
||||
"cat": "ca",
|
||||
"gle": "ga",
|
||||
"glg": "gl",
|
||||
"bul": "bg",
|
||||
"hrv": "hr",
|
||||
"srp": "sr",
|
||||
"slv": "sl",
|
||||
"mkd": "mk",
|
||||
"mac": "mk",
|
||||
"bel": "be",
|
||||
"bos": "bs",
|
||||
"ind": "id",
|
||||
"msa": "ms",
|
||||
"may": "ms",
|
||||
"tha": "th",
|
||||
"vie": "vi",
|
||||
"hin": "hi",
|
||||
"tam": "ta",
|
||||
"tel": "te",
|
||||
"urd": "ur",
|
||||
"fas": "fa",
|
||||
"per": "fa",
|
||||
"mar": "mr",
|
||||
"nno": "nn",
|
||||
"nob": "nb",
|
||||
}
|
||||
|
||||
func LanguageNameGerman(code string) string {
|
||||
normalized := strings.TrimSpace(strings.ToLower(code))
|
||||
if normalized == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
if alias, ok := languageAliases[normalized]; ok {
|
||||
normalized = alias
|
||||
}
|
||||
|
||||
tag, err := language.Parse(normalized)
|
||||
if err != nil || tag == language.Und {
|
||||
return code
|
||||
}
|
||||
|
||||
name := display.German.Languages().Name(tag)
|
||||
if name == "" {
|
||||
return code
|
||||
}
|
||||
|
||||
return name
|
||||
}
|
||||
@@ -135,6 +135,7 @@ func (e *Engine) funcs() error {
|
||||
e.AddFunc("ReplaceSlashParen", functions.ReplaceSlashParen)
|
||||
e.AddFunc("ReplaceSlashParenSlash", functions.ReplaceSlashParenSlash)
|
||||
e.AddFunc("LinksAnnotation", functions.LinksAnnotation)
|
||||
e.AddFunc("LanguageNameGerman", functions.LanguageNameGerman)
|
||||
|
||||
// Time & Date Functions
|
||||
e.AddFunc("Today", functions.Today)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -80,6 +80,30 @@
|
||||
<div class="fieldvalue">{{ $model.result.Entry.TitleStmt }}</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- if $model.result.Entry.ParallelTitle -}}
|
||||
<div class="entryrow">
|
||||
<div class="fieldlabel">Paralleltitel</div>
|
||||
<div class="fieldvalue">{{ $model.result.Entry.ParallelTitle }}</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- if $model.result.Entry.SubtitleStmt -}}
|
||||
<div class="entryrow">
|
||||
<div class="fieldlabel">Untertitel</div>
|
||||
<div class="fieldvalue">{{ $model.result.Entry.SubtitleStmt }}</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- if $model.result.Entry.VariantTitle -}}
|
||||
<div class="entryrow">
|
||||
<div class="fieldlabel">Titelvarianten</div>
|
||||
<div class="fieldvalue">{{ $model.result.Entry.VariantTitle }}</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- if $model.result.Entry.IncipitStmt -}}
|
||||
<div class="entryrow">
|
||||
<div class="fieldlabel">Incipit</div>
|
||||
<div class="fieldvalue">{{ $model.result.Entry.IncipitStmt }}</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
<div class="entryrow">
|
||||
<div class="fieldlabel">Jahr</div>
|
||||
<div class="fieldvalue">
|
||||
@@ -98,6 +122,24 @@
|
||||
<div class="fieldvalue">{{ $model.result.Entry.ResponsibilityStmt }}</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- if $model.result.Entry.PublicationStmt -}}
|
||||
<div class="entryrow">
|
||||
<div class="fieldlabel">Publikationsangabe</div>
|
||||
<div class="fieldvalue">{{ $model.result.Entry.PublicationStmt }}</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- if $model.result.Entry.PlaceStmt -}}
|
||||
<div class="entryrow">
|
||||
<div class="fieldlabel">Ortsangabe</div>
|
||||
<div class="fieldvalue">{{ $model.result.Entry.PlaceStmt }}</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- if $model.result.Entry.Edition -}}
|
||||
<div class="entryrow">
|
||||
<div class="fieldlabel">Ausgabebezeichnung</div>
|
||||
<div class="fieldvalue">{{ $model.result.Entry.Edition }}</div>
|
||||
</div>
|
||||
{{- end -}}
|
||||
{{- if $model.result.Entry.Extent -}}
|
||||
<div class="entryrow">
|
||||
<div class="fieldlabel">Umfang</div>
|
||||
@@ -111,20 +153,10 @@
|
||||
<div class="fieldlabel">Sprache</div>
|
||||
<div class="fieldvalue">
|
||||
{{- range $i, $lang := $model.result.Entry.Language -}}
|
||||
{{- if $i -}},{{- end -}}
|
||||
{{- if eq $lang "ger" -}}
|
||||
{{ $isGer = true }}
|
||||
Deutsch
|
||||
{{- else if eq $lang "eng" -}}
|
||||
{{ $isEng = true }}
|
||||
Englisch
|
||||
{{- else if eq $lang "fre" -}}
|
||||
{{ $isFra = true }}
|
||||
Französisch
|
||||
{{- else if eq $lang "ita" -}}
|
||||
Italienisch
|
||||
{{- else if eq $lang "lat" -}}
|
||||
Latein
|
||||
{{- if $i }}, {{ end -}}
|
||||
{{- $name := LanguageNameGerman $lang -}}
|
||||
{{- if $name -}}
|
||||
{{ $name }}
|
||||
{{- else -}}
|
||||
{{ $lang }}
|
||||
{{- end -}}
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
}
|
||||
|
||||
.rel-grid {
|
||||
@apply grid grid-cols-[1fr_14rem_5.5rem_7rem] gap-3 items-center;
|
||||
@apply grid grid-cols-[1fr_12.5rem_5rem_7rem] gap-3 items-center;
|
||||
}
|
||||
|
||||
.rel-name-col {
|
||||
|
||||
Reference in New Issue
Block a user