mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-01 17:38:33 +00:00
Allow using localized absolute date times within phrases with place holders and localize issue due date events (#24275)
This refactors the `shared/datetime/short|long|full` templates into a template helper function, which allows us to render absolute date times within translatable phrases. - Follows #23988 - The first attempt was in #24055 - This should help #22664 Changes: 1. Added the `DateTime` template helper that replaces the `shared/datetime/short|long|full` templates 2. Used find-and-replace with varying regexes to replace the templates from step 1 (for example, `\{\{template "shared/datetime/(\S+) \(dict "Datetime" ([^"]+) "Fallback" ([^\)]+\)?) ?\)?\}\}` -> `{{DateTime "$1 $2 $3}}`) 3. Used the new `DateTime` helper in the issue due date timestamp rendering # Before  # After  --------- Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
cbe2e99aed
commit
70bb4984cd
33 changed files with 64 additions and 39 deletions
|
@ -22,7 +22,7 @@
|
|||
<td><a href="{{.FullWebLink}}">{{.Version.Version}}</a></td>
|
||||
<td><a href="{{.Creator.HomeLink}}">{{.Creator.Name}}</a></td>
|
||||
<td>{{FileSize .CalculateBlobSize}}</td>
|
||||
<td>{{template "shared/datetime/short" (dict "Datetime" .Version.CreatedUnix.FormatLong "Fallback" .Version.CreatedUnix.FormatShort)}}</td>
|
||||
<td>{{DateTime "short" .Version.CreatedUnix.FormatLong .Version.CreatedUnix.FormatShort}}</td>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr>
|
||||
|
|
|
@ -86,7 +86,7 @@
|
|||
{{range .LatestVersions}}
|
||||
<div class="item gt-df">
|
||||
<a class="gt-f1" href="{{$.PackageDescriptor.PackageWebLink}}/{{PathEscape .LowerVersion}}">{{.Version}}</a>
|
||||
<span class="text small">{{template "shared/datetime/short" (dict "Datetime" (.CreatedUnix.FormatDate) "Fallback" (.CreatedUnix.FormatDate))}}</span>
|
||||
<span class="text small">{{DateTime "short" (.CreatedUnix.FormatDate) (.CreatedUnix.FormatDate)}}</span>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue