BUGFIX: mor langauages in almach view

This commit is contained in:
Simon Martens
2026-01-14 21:40:48 +01:00
parent ff5f080f6c
commit b1e0238b5a
6 changed files with 172 additions and 20 deletions

View File

@@ -34,10 +34,27 @@ func SearchPlaces(app core.App, term string, limit int) ([]*Place, error) {
Limit(int64(limit)) Limit(int64(limit))
if trimmed != "" { if trimmed != "" {
query = query.Where(dbx.Or( terms := []string{trimmed}
dbx.Like(PLACES_NAME_FIELD, trimmed).Match(true, true), if strings.Contains(trimmed, "/") {
dbx.Like(PLACES_PSEUDONYMS_FIELD, trimmed).Match(true, true), 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 { if err := query.All(&places); err != nil {

View 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
}

View File

@@ -135,6 +135,7 @@ func (e *Engine) funcs() error {
e.AddFunc("ReplaceSlashParen", functions.ReplaceSlashParen) e.AddFunc("ReplaceSlashParen", functions.ReplaceSlashParen)
e.AddFunc("ReplaceSlashParenSlash", functions.ReplaceSlashParenSlash) e.AddFunc("ReplaceSlashParenSlash", functions.ReplaceSlashParenSlash)
e.AddFunc("LinksAnnotation", functions.LinksAnnotation) e.AddFunc("LinksAnnotation", functions.LinksAnnotation)
e.AddFunc("LanguageNameGerman", functions.LanguageNameGerman)
// Time & Date Functions // Time & Date Functions
e.AddFunc("Today", functions.Today) e.AddFunc("Today", functions.Today)

File diff suppressed because one or more lines are too long

View File

@@ -80,6 +80,30 @@
<div class="fieldvalue">{{ $model.result.Entry.TitleStmt }}</div> <div class="fieldvalue">{{ $model.result.Entry.TitleStmt }}</div>
</div> </div>
{{- end -}} {{- 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="entryrow">
<div class="fieldlabel">Jahr</div> <div class="fieldlabel">Jahr</div>
<div class="fieldvalue"> <div class="fieldvalue">
@@ -98,6 +122,24 @@
<div class="fieldvalue">{{ $model.result.Entry.ResponsibilityStmt }}</div> <div class="fieldvalue">{{ $model.result.Entry.ResponsibilityStmt }}</div>
</div> </div>
{{- end -}} {{- 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 -}} {{- if $model.result.Entry.Extent -}}
<div class="entryrow"> <div class="entryrow">
<div class="fieldlabel">Umfang</div> <div class="fieldlabel">Umfang</div>
@@ -111,20 +153,10 @@
<div class="fieldlabel">Sprache</div> <div class="fieldlabel">Sprache</div>
<div class="fieldvalue"> <div class="fieldvalue">
{{- range $i, $lang := $model.result.Entry.Language -}} {{- range $i, $lang := $model.result.Entry.Language -}}
{{- if $i -}},{{- end -}} {{- if $i }}, {{ end -}}
{{- if eq $lang "ger" -}} {{- $name := LanguageNameGerman $lang -}}
{{ $isGer = true }} {{- if $name -}}
Deutsch {{ $name }}
{{- 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
{{- else -}} {{- else -}}
{{ $lang }} {{ $lang }}
{{- end -}} {{- end -}}

View File

@@ -144,7 +144,7 @@
} }
.rel-grid { .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 { .rel-name-col {