1
0
Fork 0

[I18N] Injected updated time in translation string (#3837)

Hello,

It is more idiomatic to put the date/time before the action in Mandarin (in this context). To achieve this, instead of having the time following the string that's passed to the translating function, I added it as a parameter so that one can reference it and reorder the sentence for better translatability.

Only Traditional Chinese has been changed at the time of opening this PR, as this is more of a proof of concept and I would like to have feedbacks on whether this is a good solution or is there a better alternative.

Thank you and have a nice day :)

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3837
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Co-authored-by: Léana 江 <leana.jiang+git@icloud.com>
Co-committed-by: Léana 江 <leana.jiang+git@icloud.com>
This commit is contained in:
Léana 江 2024-05-20 18:47:35 +00:00 committed by 0ko
parent bcd2e64a93
commit 3561cc710b
33 changed files with 104 additions and 33 deletions

View file

@ -503,7 +503,7 @@ settings.delete_org_desc = هذه المنظمة ستحذف إلى الأبد،
create_org = أنشئ منظمة create_org = أنشئ منظمة
teams.add_all_repos_desc = سيضيف هذا كل مستودعات المنظمة إلى الفريق. teams.add_all_repos_desc = سيضيف هذا كل مستودعات المنظمة إلى الفريق.
settings.labels_desc = أضف التصنيفات القابلة للاستخدام في المسائل التابعة <strong>لكل مستودعات</strong> هذه المنظمة. settings.labels_desc = أضف التصنيفات القابلة للاستخدام في المسائل التابعة <strong>لكل مستودعات</strong> هذه المنظمة.
repo_updated = حُدِّث repo_updated = حُدِّث %s
org_desc = الوصف org_desc = الوصف
org_name_helper = ينبغي أن تكون أسماء المنظمات قصيرة وسهلة التذكر. org_name_helper = ينبغي أن تكون أسماء المنظمات قصيرة وسهلة التذكر.
team_permission_desc = الأذونات team_permission_desc = الأذونات

View file

@ -1210,7 +1210,7 @@ settings.delete_prompt = Организацията ще бъде премахн
settings.labels_desc = Добавете етикети, които могат да се използват за задачи за <strong>всички хранилища</strong> в тази организация. settings.labels_desc = Добавете етикети, които могат да се използват за задачи за <strong>всички хранилища</strong> в тази организация.
teams.none_access = Без достъп teams.none_access = Без достъп
teams.members.none = Няма членове в този екип. teams.members.none = Няма членове в този екип.
repo_updated = Обновено repo_updated = Обновено %s
teams.delete_team_success = Екипът е изтрит. teams.delete_team_success = Екипът е изтрит.
teams.search_repo_placeholder = Потърсете хранилище… teams.search_repo_placeholder = Потърсете хранилище…
teams.delete_team_title = Изтриване на екипа teams.delete_team_title = Изтриване на екипа

View file

@ -2772,7 +2772,7 @@ org_name_holder=Název organizace
org_full_name_holder=Celý název organizace org_full_name_holder=Celý název organizace
org_name_helper=Jména organizací by měla být krátká a zapamatovatelná. org_name_helper=Jména organizací by měla být krátká a zapamatovatelná.
create_org=Vytvořit organizaci create_org=Vytvořit organizaci
repo_updated=Upraveno repo_updated=Upraveno %s
members=Členové members=Členové
teams=Týmy teams=Týmy
code=Kód code=Kód

View file

@ -2749,7 +2749,7 @@ org_name_holder=Name der Organisation
org_full_name_holder=Vollständiger Name der Organisation org_full_name_holder=Vollständiger Name der Organisation
org_name_helper=Organisationsnamen sollten kurz und einprägsam sein. org_name_helper=Organisationsnamen sollten kurz und einprägsam sein.
create_org=Organisation erstellen create_org=Organisation erstellen
repo_updated=Aktualisiert repo_updated=Aktualisiert %s
members=Mitglieder members=Mitglieder
teams=Teams teams=Teams
code=Quelltext code=Quelltext

View file

@ -2737,7 +2737,7 @@ org_name_holder=Όνομα οργανισμού
org_full_name_holder=Πλήρες όνομα οργανισμού org_full_name_holder=Πλήρες όνομα οργανισμού
org_name_helper=Τα ονόματα οργανισμών θα πρέπει να είναι σύντομα και εύκολα στην απομνημόνευση. org_name_helper=Τα ονόματα οργανισμών θα πρέπει να είναι σύντομα και εύκολα στην απομνημόνευση.
create_org=Δημιουργία οργανισμού create_org=Δημιουργία οργανισμού
repo_updated=Ενημερώθηκε repo_updated=Ενημερώθηκε %s
members=Μέλη members=Μέλη
teams=Ομάδες teams=Ομάδες
code=Κώδικας code=Κώδικας

View file

@ -2732,7 +2732,7 @@ org_full_name_holder = Organization full name
org_name_helper = Organization names should be short and memorable. org_name_helper = Organization names should be short and memorable.
create_org = Create organization create_org = Create organization
open_dashboard = Open dashboard open_dashboard = Open dashboard
repo_updated = Updated repo_updated = Updated %s
members = Members members = Members
teams = Teams teams = Teams
code = Code code = Code

View file

@ -2623,7 +2623,7 @@ org_name_holder=Nombre de la organización
org_full_name_holder=Nombre completo de la organización org_full_name_holder=Nombre completo de la organización
org_name_helper=Los nombres de organización deben ser cortos y destacados. org_name_helper=Los nombres de organización deben ser cortos y destacados.
create_org=Crear Organización create_org=Crear Organización
repo_updated=Actualizado repo_updated=Actualizado %s
members=Miembros members=Miembros
teams=Equipos teams=Equipos
code=Código code=Código

View file

@ -1981,7 +1981,7 @@ org_name_holder=نام سازمان
org_full_name_holder=نام کامل سازمان org_full_name_holder=نام کامل سازمان
org_name_helper=نام سازمان باید کوتاه و قابل حفظ کردن باشد. org_name_helper=نام سازمان باید کوتاه و قابل حفظ کردن باشد.
create_org=ایجاد سازمان create_org=ایجاد سازمان
repo_updated=به روز رسانی شده repo_updated=به روز رسانی شده %s
members=اعضاء members=اعضاء
teams=تیم‌ها teams=تیم‌ها
lower_members=اعضا lower_members=اعضا

View file

@ -1352,7 +1352,7 @@ org_name_holder=Organisaatio
org_full_name_holder=Organisaation täydellinen nimi org_full_name_holder=Organisaation täydellinen nimi
org_name_helper=Organisaation nimen tulisi olla lyhyt ja mieleenpainuva. org_name_helper=Organisaation nimen tulisi olla lyhyt ja mieleenpainuva.
create_org=Luo organisaatio create_org=Luo organisaatio
repo_updated=Päivitetty repo_updated=Päivitetty %s
members=Jäsenet members=Jäsenet
teams=Tiimit teams=Tiimit
lower_members=jäsenet lower_members=jäsenet

View file

@ -1827,7 +1827,7 @@ config.ssh_keygen_path = Path ng keygen ("ssh-keygen")
config.ssh_key_test_path = Path ng key test config.ssh_key_test_path = Path ng key test
[org] [org]
repo_updated = Binago repo_updated = Binago %s
team_access_desc = Access ng repositoryo team_access_desc = Access ng repositoryo
team_permission_desc = Pahintulot team_permission_desc = Pahintulot
org_desc = Deskripsyon org_desc = Deskripsyon

View file

@ -2769,7 +2769,7 @@ org_name_holder=Nom de l'organisation
org_full_name_holder=Nom complet de l'organisation org_full_name_holder=Nom complet de l'organisation
org_name_helper=Le nom de l'organisation doit être court et mémorable. org_name_helper=Le nom de l'organisation doit être court et mémorable.
create_org=Créer une organisation create_org=Créer une organisation
repo_updated=Actualisé repo_updated=Actualisé %s
members=Membres members=Membres
teams=Équipes teams=Équipes
code=Code code=Code

View file

@ -1179,7 +1179,7 @@ org_name_holder=Szervezet neve
org_full_name_holder=Szervezet teljes neve org_full_name_holder=Szervezet teljes neve
org_name_helper=A szervezetek nevének rövidnek és megjegyezhetőnek kell lennie. org_name_helper=A szervezetek nevének rövidnek és megjegyezhetőnek kell lennie.
create_org=Szervezet létrehozása create_org=Szervezet létrehozása
repo_updated=Frissítve repo_updated=Frissítve %s
members=Tagok members=Tagok
teams=Csoportok teams=Csoportok
lower_members=tagok lower_members=tagok

View file

@ -963,7 +963,7 @@ branch.deleted_by=Dihapus oleh %s
org_name_holder=Nama Organisasi org_name_holder=Nama Organisasi
org_full_name_holder=Organisasi Nama Lengkap org_full_name_holder=Organisasi Nama Lengkap
create_org=Buat Organisasi create_org=Buat Organisasi
repo_updated=Diperbarui repo_updated=Diperbarui %s
members=Anggota members=Anggota
teams=Tim teams=Tim
lower_members=anggota lower_members=anggota

View file

@ -1120,7 +1120,7 @@ topic.done=Í lagi
[graphs] [graphs]
[org] [org]
repo_updated=Uppfært repo_updated=Uppfært %s
members=Meðlimar members=Meðlimar
teams=Lið teams=Lið
lower_members=meðlimar lower_members=meðlimar

View file

@ -2748,7 +2748,7 @@ org_name_holder=Nome dell'organizzazione
org_full_name_holder=Nome completo dell'organizzazione org_full_name_holder=Nome completo dell'organizzazione
org_name_helper=I nomi delle organizzazioni devono essere brevi e semplici da ricordare. org_name_helper=I nomi delle organizzazioni devono essere brevi e semplici da ricordare.
create_org=Crea organizzazione create_org=Crea organizzazione
repo_updated=Aggiornato repo_updated=Aggiornato %s
members=Membri members=Membri
teams=Team teams=Team
lower_members=membri lower_members=membri

View file

@ -2745,7 +2745,7 @@ org_name_holder=組織名
org_full_name_holder=組織のフルネーム org_full_name_holder=組織のフルネーム
org_name_helper=組織名は短く覚えやすいものにしましょう。 org_name_helper=組織名は短く覚えやすいものにしましょう。
create_org=組織を作成 create_org=組織を作成
repo_updated=最終更新 repo_updated=最終更新 %s
members=メンバー members=メンバー
teams=チーム teams=チーム
code=コード code=コード

View file

@ -1283,7 +1283,7 @@ pulls.blocked_by_official_review_requests = 이 풀 리퀘스트는 공식 검
org_name_holder=조직 이름 org_name_holder=조직 이름
org_full_name_holder=조직 전체 이름 org_full_name_holder=조직 전체 이름
create_org=새로운 조직 create_org=새로운 조직
repo_updated=업데이트됨 repo_updated=업데이트됨 %s
members=멤버 members=멤버
teams= teams=
lower_members=회원 lower_members=회원

View file

@ -2581,7 +2581,7 @@ org_name_holder=Organizācijas nosaukums
org_full_name_holder=Organizācijas pilnais nosaukums org_full_name_holder=Organizācijas pilnais nosaukums
org_name_helper=Organizāciju nosaukumiem vēlams būt īsiem un tādiem, ko viegli atcerēties. org_name_helper=Organizāciju nosaukumiem vēlams būt īsiem un tādiem, ko viegli atcerēties.
create_org=Izveidot organizāciju create_org=Izveidot organizāciju
repo_updated=Atjaunināts repo_updated=Atjaunināts %s
members=Dalībnieki members=Dalībnieki
teams=Komandas teams=Komandas
code=Kods code=Kods

View file

@ -2731,7 +2731,7 @@ org_name_holder=Organisatienaam
org_full_name_holder=Volledige naam organisatie org_full_name_holder=Volledige naam organisatie
org_name_helper=Organisatienamen horen kort en memorabel zijn. org_name_helper=Organisatienamen horen kort en memorabel zijn.
create_org=Nieuwe organisatie aanmaken create_org=Nieuwe organisatie aanmaken
repo_updated=Geupdate repo_updated=Geupdate %s
members=Leden members=Leden
teams=Teams teams=Teams
lower_members=leden lower_members=leden

View file

@ -2033,7 +2033,7 @@ org_name_holder=Nazwa organizacji
org_full_name_holder=Pełna nazwa organizacji org_full_name_holder=Pełna nazwa organizacji
org_name_helper=Nazwa organizacji powinna być krótka i łatwa do zapamiętania. org_name_helper=Nazwa organizacji powinna być krótka i łatwa do zapamiętania.
create_org=Utwórz organizację create_org=Utwórz organizację
repo_updated=Zaktualizowano repo_updated=Zaktualizowano %s
members=Członkowie members=Członkowie
teams=Zespoły teams=Zespoły
lower_members=członkowie lower_members=członkowie

View file

@ -2610,7 +2610,7 @@ org_name_holder=Nome da organização
org_full_name_holder=Nome completo da organização org_full_name_holder=Nome completo da organização
org_name_helper=Nomes de organização devem ser curtos e memoráveis. org_name_helper=Nomes de organização devem ser curtos e memoráveis.
create_org=Criar organização create_org=Criar organização
repo_updated=Atualizado repo_updated=Atualizado %s
members=Membros members=Membros
teams=Equipes teams=Equipes
code=Código code=Código

View file

@ -2750,7 +2750,7 @@ org_name_holder=Nome da organização
org_full_name_holder=Nome completo da organização org_full_name_holder=Nome completo da organização
org_name_helper=Nomes das organizações devem ser curtos e memoráveis. org_name_helper=Nomes das organizações devem ser curtos e memoráveis.
create_org=Criar organização create_org=Criar organização
repo_updated=Modificado repo_updated=Modificado %s
members=Membros members=Membros
teams=Equipas teams=Equipas
code=Código code=Código

View file

@ -2749,7 +2749,7 @@ org_name_holder=Название организации
org_full_name_holder=Полное название org_full_name_holder=Полное название
org_name_helper=Лучшие названия организаций коротки и запоминаемы. org_name_helper=Лучшие названия организаций коротки и запоминаемы.
create_org=Создать организацию create_org=Создать организацию
repo_updated=Обновлено repo_updated=Обновлено %s
members=Участники members=Участники
teams=Команды teams=Команды
code=Код code=Код

View file

@ -1921,7 +1921,7 @@ org_name_holder=සංවිධානයේ නම
org_full_name_holder=සංවිධානයේ සම්පූර්ණ නම org_full_name_holder=සංවිධානයේ සම්පූර්ණ නම
org_name_helper=සංවිධාන නම් කෙටි හා අමතක නොවන විය යුතුය. org_name_helper=සංවිධාන නම් කෙටි හා අමතක නොවන විය යුතුය.
create_org=සංවිධානය සාදන්න create_org=සංවිධානය සාදන්න
repo_updated=යාවත්කාල කෙරිණි repo_updated=යාවත්කාල කෙරිණි %s
members=සාමාජිකයින් members=සාමාජිකයින්
teams=කණ්ඩායම් teams=කණ්ඩායම්
lower_members=සාමාජිකයින් lower_members=සාමාජිකයින්

View file

@ -1546,7 +1546,7 @@ org_name_holder=Organisationsnamn
org_full_name_holder=Organisationens Fullständiga Namn org_full_name_holder=Organisationens Fullständiga Namn
org_name_helper=Organisationsnamn bör vara korta och enkla att komma ihåg. org_name_helper=Organisationsnamn bör vara korta och enkla att komma ihåg.
create_org=Skapa organisation create_org=Skapa organisation
repo_updated=Uppdaterad repo_updated=Uppdaterad %s
members=Medlemmar members=Medlemmar
teams=Grupper teams=Grupper
lower_members=medlemmar lower_members=medlemmar

View file

@ -2591,7 +2591,7 @@ org_name_holder=Organizasyon Adı
org_full_name_holder=Organizasyon Tam Adı org_full_name_holder=Organizasyon Tam Adı
org_name_helper=Organizasyon adları kısa ve hatırlanabilir olmalıdır. org_name_helper=Organizasyon adları kısa ve hatırlanabilir olmalıdır.
create_org=Organizasyon Oluştur create_org=Organizasyon Oluştur
repo_updated=Güncellendi repo_updated=Güncellendi %s
members=Üyeler members=Üyeler
teams=Takımlar teams=Takımlar
code=Kod code=Kod

View file

@ -2078,7 +2078,7 @@ org_name_holder=Назва організації
org_full_name_holder=Повна назва організації org_full_name_holder=Повна назва організації
org_name_helper=Назва організації має бути простою та зрозумілою. org_name_helper=Назва організації має бути простою та зрозумілою.
create_org=Створити організацію create_org=Створити організацію
repo_updated=Оновлено repo_updated=Оновлено %s
members=Учасники members=Учасники
teams=Команди teams=Команди
lower_members=учасники lower_members=учасники

View file

@ -2767,7 +2767,7 @@ org_name_holder=组织名称
org_full_name_holder=组织全名 org_full_name_holder=组织全名
org_name_helper=组织名字应该简单明了。 org_name_helper=组织名字应该简单明了。
create_org=创建组织 create_org=创建组织
repo_updated=最后更新于 repo_updated=于 %s 更新
members=成员 members=成员
teams=团队 teams=团队
code=代码 code=代码

View file

@ -676,7 +676,7 @@ release.downloads=下載附件
org_name_holder=組織名稱 org_name_holder=組織名稱
org_full_name_holder=組織全名 org_full_name_holder=組織全名
create_org=建立組織 create_org=建立組織
repo_updated=最後更新於 repo_updated=最後更新於 %s
members=成員數 members=成員數
teams=組織團隊 teams=組織團隊
lower_members=名成員 lower_members=名成員

View file

@ -2511,7 +2511,7 @@ org_name_holder=組織名稱
org_full_name_holder=組織全名 org_full_name_holder=組織全名
org_name_helper=組織名稱應該要簡短且方便記憶 org_name_helper=組織名稱應該要簡短且方便記憶
create_org=建立組織 create_org=建立組織
repo_updated=更新 repo_updated=於 %s 更新
members=成員 members=成員
teams=團隊 teams=團隊
code=程式碼 code=程式碼

View file

@ -62,7 +62,7 @@
{{end}} {{end}}
</div> </div>
{{end}} {{end}}
<div class="flex-item-body">{{ctx.Locale.Tr "org.repo_updated"}} {{TimeSinceUnix .UpdatedUnix ctx.Locale}}</div> <div class="flex-item-body">{{ctx.Locale.Tr "org.repo_updated" (TimeSinceUnix .UpdatedUnix ctx.Locale)}}</div>
</div> </div>
</div> </div>
{{else}} {{else}}

View file

@ -25,7 +25,7 @@
<button class="btn interact-fg tw-px-1" data-clipboard-text="{{.DefaultBranchBranch.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button> <button class="btn interact-fg tw-px-1" data-clipboard-text="{{.DefaultBranchBranch.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button>
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DefaultBranchBranch.DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DefaultBranchBranch.DBBranch.CommitID)}} {{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DefaultBranchBranch.DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DefaultBranchBranch.DBBranch.CommitID)}}
</div> </div>
<p class="info tw-flex tw-items-center tw-my-1">{{svg "octicon-git-commit" 16 "tw-mr-1"}}<a href="{{.RepoLink}}/commit/{{PathEscape .DefaultBranchBranch.DBBranch.CommitID}}">{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage (.Repository.ComposeMetas ctx)}}</span> · {{ctx.Locale.Tr "org.repo_updated"}} {{TimeSince .DefaultBranchBranch.DBBranch.CommitTime.AsTime ctx.Locale}}{{if .DefaultBranchBranch.DBBranch.Pusher}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}</p> <p class="info tw-flex tw-items-center tw-my-1">{{svg "octicon-git-commit" 16 "tw-mr-1"}}<a href="{{.RepoLink}}/commit/{{PathEscape .DefaultBranchBranch.DBBranch.CommitID}}">{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage (.Repository.ComposeMetas ctx)}}</span> · {{ctx.Locale.Tr "org.repo_updated" (TimeSince .DefaultBranchBranch.DBBranch.CommitTime.AsTime ctx.Locale)}} {{if .DefaultBranchBranch.DBBranch.Pusher}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}</p>
</td> </td>
<td class="right aligned middle aligned overflow-visible"> <td class="right aligned middle aligned overflow-visible">
{{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}} {{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}}
@ -98,7 +98,7 @@
<button class="btn interact-fg tw-px-1" data-clipboard-text="{{.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button> <button class="btn interact-fg tw-px-1" data-clipboard-text="{{.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button>
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DBBranch.CommitID)}} {{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DBBranch.CommitID)}}
</div> </div>
<p class="info tw-flex tw-items-center tw-my-1">{{svg "octicon-git-commit" 16 "tw-mr-1"}}<a href="{{$.RepoLink}}/commit/{{PathEscape .DBBranch.CommitID}}">{{ShortSha .DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DBBranch.CommitMessage ($.Repository.ComposeMetas ctx)}}</span> · {{ctx.Locale.Tr "org.repo_updated"}} {{TimeSince .DBBranch.CommitTime.AsTime ctx.Locale}}{{if .DBBranch.Pusher}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}} &nbsp;{{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p> <p class="info tw-flex tw-items-center tw-my-1">{{svg "octicon-git-commit" 16 "tw-mr-1"}}<a href="{{$.RepoLink}}/commit/{{PathEscape .DBBranch.CommitID}}">{{ShortSha .DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DBBranch.CommitMessage ($.Repository.ComposeMetas ctx)}}</span> · {{ctx.Locale.Tr "org.repo_updated" (TimeSince .DBBranch.CommitTime.AsTime ctx.Locale)}} {{if .DBBranch.Pusher}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}} &nbsp;{{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p>
{{end}} {{end}}
</td> </td>
<td class="two wide ui"> <td class="two wide ui">

View file

@ -0,0 +1,71 @@
package integration
import (
"net/http"
"net/url"
"path"
"strings"
"testing"
"github.com/PuerkitoBio/goquery"
"github.com/stretchr/testify/assert"
)
func TestRepoLastUpdatedTime(t *testing.T) {
onGiteaRun(t, func(t *testing.T, u *url.URL) {
user := "user2"
session := loginUser(t, user)
req := NewRequest(t, "GET", path.Join("explore", "repos"))
resp := session.MakeRequest(t, req, http.StatusOK)
doc := NewHTMLParser(t, resp.Body)
node := doc.doc.Find(".flex-item-body").First()
{
buf := ""
findTextNonNested(t, node, &buf)
assert.Equal(t, "Updated", strings.TrimSpace(buf))
}
// Relative time should be present as a descendent
{
relativeTime := node.Find("relative-time").Text()
assert.Equal(t, true, strings.HasPrefix(relativeTime, "19")) // ~1970, might underflow with timezone
}
})
}
func TestBranchLastUpdatedTime(t *testing.T) {
onGiteaRun(t, func(t *testing.T, u *url.URL) {
user := "user2"
repo := "repo1"
session := loginUser(t, user)
req := NewRequest(t, "GET", path.Join(user, repo, "branches"))
resp := session.MakeRequest(t, req, http.StatusOK)
doc := NewHTMLParser(t, resp.Body)
node := doc.doc.Find("p:has(span.commit-message)")
{
buf := ""
findTextNonNested(t, node, &buf)
assert.Equal(t, true, strings.Contains(buf, "Updated"))
}
{
relativeTime := node.Find("relative-time").Text()
assert.Equal(t, true, strings.HasPrefix(relativeTime, "2017"))
}
})
}
// Find all text that are direct descendents
func findTextNonNested(t *testing.T, n *goquery.Selection, buf *string) {
t.Helper()
n.Contents().Each(func(i int, s *goquery.Selection) {
if goquery.NodeName(s) == "#text" {
*buf += s.Text()
}
})
}