Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Title format is not configurable

Đang mở
#272 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
42/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
javascript
Lĩnh vực
frontend, localization

Hướng nghiên cứu

Bắt đầu với src/relative-time-element.ts, tại phần mã định dạng tiêu đề được liên kết trong issue, sau đó kiểm tra các tùy chọn định dạng hiện có và các bài kiểm thử liên quan. Xác định và triển khai cách định dạng tiêu đề sử dụng lại các thiết lập kiểu hoặc chấp nhận một quy tắc độc lập, đồng thời giữ nguyên việc định dạng theo múi giờ cục bộ của trình duyệt; hoàn tất khi tiêu đề hỗ trợ định dạng bản địa hóa được yêu cầu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Hello, and thanks for this custom element!

I am starting to use <relative-time> in an app that supports multiple languages and users are in different countries. I started with the basics and just set the datetime attribute and inner text.

I noticed the automatic title always had short months. I tried to change it by setting formatStyle="long" and month="long" to no avail. Inspecting the source I found that titles use a fixed format:

https://github.com/github/relative-time-element/blob/7e40806f21684e46573e202527b9505e723d13e8/src/relative-time-element.ts#L116-L130

Thanks to the comment in the code above, I was able to temporarily solve for my use case by rendering the title from the server side, but that meant giving up showing the time in the timezone of the browser.

Would you consider re-using the style settings when formatting the title or provide a specific formatting rule for the title, independent from the inner text?

PS: Related, but less important, it would also be useful to add some text around the date, like title="Updated at {formatted-date-here}" (where the string "Updated at" is rendered in the correct locale on the server).

Thanks again!

Ngôn ngữ chính
JavaScript
Star
4k
Fork
194
Merge trung bình
4 ngày 10 giờ
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của github/relative-time-element

Tất cả issue của github/relative-time-element

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.