attachments: support i18n for attachment size #21

This commit is contained in:
Sören Weber 2021-07-17 12:37:24 +02:00
parent 919c826f8c
commit 4d5d7f6815
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
15 changed files with 130 additions and 49 deletions

View file

@ -0,0 +1 @@
This is a small text

View file

@ -25,8 +25,14 @@ other = "المزيد"
[Expand-title]
other = "...قم بتوسيع"
[BinaryPrefix-kilobyte]
other = "kb"
[Byte-symbol]
other = "B"
[Kilobyte-symbol]
other = "KB"
[Megabyte-symbol]
other = "MB"
[note]
other = "Note"

View file

@ -25,8 +25,14 @@ other = "Mehr"
[Expand-title]
other = "Erweitere mich..."
[BinaryPrefix-kilobyte]
other = "kb"
[Byte-symbol]
other = "B"
[Kilobyte-symbol]
other = "KB"
[Megabyte-symbol]
other = "MB"
[note]
other = "Anmerkung"

View file

@ -25,8 +25,14 @@ other = "More"
[Expand-title]
other = "Expand me..."
[BinaryPrefix-kilobyte]
other = "kb"
[Byte-symbol]
other = "B"
[Kilobyte-symbol]
other = "KB"
[Megabyte-symbol]
other = "MB"
[note]
other = "Note"

View file

@ -25,8 +25,14 @@ other = "Más"
[Expand-title]
other = "Expandir..."
[BinaryPrefix-kilobyte]
other = "kb"
[Byte-symbol]
other = "B"
[Kilobyte-symbol]
other = "KB"
[Megabyte-symbol]
other = "MB"
[note]
other = "Nota"

View file

@ -25,9 +25,15 @@ other = "Aller plus loin"
[Expand-title]
other = "Déroulez-moi..."
[BinaryPrefix-kilobyte]
[Byte-symbol]
other = "o"
[Kilobyte-symbol]
other = "ko"
[Megabyte-symbol]
other = "Mo"
[note]
other = "Remarque"

View file

@ -25,8 +25,14 @@ other = "अधिक सामग्री दिखाएं"
[Expand-title]
other = "विस्तार करे..."
[BinaryPrefix-kilobyte]
other = "kb"
[Byte-symbol]
other = "B"
[Kilobyte-symbol]
other = "KB"
[Megabyte-symbol]
other = "MB"
[note]
other = "Note"

View file

@ -25,8 +25,14 @@ other = "Lainnya"
[Expand-title]
other = "Bentangkan..."
[BinaryPrefix-kilobyte]
other = "kb"
[Byte-symbol]
other = "B"
[Kilobyte-symbol]
other = "KB"
[Megabyte-symbol]
other = "MB"
[note]
other = "Note"

View file

@ -25,8 +25,14 @@ other = "更に"
[Expand-title]
other = "開く..."
[BinaryPrefix-kilobyte]
other = "kb"
[Byte-symbol]
other = "B"
[Kilobyte-symbol]
other = "KB"
[Megabyte-symbol]
other = "MB"
[note]
other = "Note"

View file

@ -25,8 +25,14 @@ other = "Snelkoppelingen"
[Expand-title]
other = "Lees meer..."
[BinaryPrefix-kilobyte]
other = "kb"
[Byte-symbol]
other = "B"
[Kilobyte-symbol]
other = "KB"
[Megabyte-symbol]
other = "MB"
[note]
other = "Note"

View file

@ -25,8 +25,14 @@ other = "Mais"
[Expand-title]
other = "Expandir..."
[BinaryPrefix-kilobyte]
other = "kb"
[Byte-symbol]
other = "B"
[Kilobyte-symbol]
other = "KB"
[Megabyte-symbol]
other = "MB"
[note]
other = "Nota"

View file

@ -25,8 +25,14 @@ other = "Еще"
[Expand-title]
other = "Развернуть..."
[BinaryPrefix-kilobyte]
other = "килобайт"
[Byte-symbol]
other = "Б"
[Kilobyte-symbol]
other = "КБ"
[Megabyte-symbol]
other = "МБ"
[note]
other = "Заметка"

View file

@ -25,8 +25,14 @@ other = "Dahası Var"
[Expand-title]
other = "Genişlet..."
[BinaryPrefix-kilobyte]
other = "kb"
[Byte-symbol]
other = "B"
[Kilobyte-symbol]
other = "KB"
[Megabyte-symbol]
other = "MB"
[note]
other = "Note"

View file

@ -25,8 +25,14 @@ other = "更多"
[Expand-title]
other = "展开"
[BinaryPrefix-kilobyte]
other = "kb"
[Byte-symbol]
other = "B"
[Kilobyte-symbol]
other = "KB"
[Megabyte-symbol]
other = "MB"
[note]
other = "注释"

View file

@ -3,32 +3,34 @@
{{ $title := .Get "title" | default ("Attachments-label" | T) }}
<section class="attachments {{ $style }}">
<div class="label">{{ $title }}</div>
{{if eq .Page.File.BaseFileName "index"}}
{{$.Scratch.Add "filesName" "files"}}
{{else}}
{{$.Scratch.Add "filesName" (printf "%s.files" .Page.File.BaseFileName)}}
{{end}}
<div class="attachments-files">
{{ range (readDir (printf "./content/%s%s" .Page.File.Dir ($.Scratch.Get "filesName")) ) }}
{{ $fileDir := replace $.Page.File.Dir "\\" "/" }}
{{if ($.Get "pattern")}}
{{if (findRE ($.Get "pattern") .Name)}}
{{- $filesName := "files" }}
{{- if ne .Page.File.BaseFileName "index" }}
{{- $filesName = printf "%s.files" .Page.File.BaseFileName }}
{{- end}}
{{- $fileDir := replace .Page.File.Dir "\\" "/" }}
{{- $pattern := .Get "pattern" | default "" }}
{{- range (readDir (printf "content/%s%s" .Page.File.Dir $filesName) ) }}
{{- if findRE $pattern .Name}}
{{- $size := .Size }}
{{- $unit := "Byte-symbol" }}
{{- if ge $size 1024 }}
{{- $size = div $size 1024 }}
{{- $unit = "Kilobyte-symbol" }}
{{- end }}
{{- if ge $size 1024 }}
{{- $size = div $size 1024 }}
{{- $unit = "Megabyte-symbol" }}
{{- end }}
{{- $unitsymbol := $unit | T }}
<li>
<a href="{{ (printf "%s%s/%s" $fileDir ($.Scratch.Get "filesName") .Name) | relURL }}" >
{{.Name}}
</a>
({{div .Size 1024 }} {{T "BinaryPrefix-kilobyte"}})
<a href="{{ (printf "%s%s/%s" $fileDir $filesName .Name) | relLangURL }}">{{.Name}}</a>
({{$size}} {{$unitsymbol}})
</li>
{{end}}
{{else}}
<li>
<a href="{{ (printf "%s%s/%s" $fileDir ($.Scratch.Get "filesName") .Name) | relURL }}" >
{{.Name}}
</a>
({{div .Size 1024 }} {{T "BinaryPrefix-kilobyte"}})
</li>
{{end}}
{{end}}
{{- end }}
{{- end }}
</div>
{{.Inner}}
{{- .Inner }}
</section>