Skip to content

fix: 日付バインディングが locale で曜日/月名を翻訳する問題を修正#3

Merged
mt8 merged 1 commit intomainfrom
issue/1
Apr 27, 2026
Merged

fix: 日付バインディングが locale で曜日/月名を翻訳する問題を修正#3
mt8 merged 1 commit intomainfrom
issue/1

Conversation

@mt8
Copy link
Copy Markdown
Owner

@mt8 mt8 commented Apr 27, 2026

Closes #1

Summary

`wp_date()` / `get_the_date()` が D/M/l/F format をサイト locale に翻訳するため、`{{now:r}}` / `{{feed.last_build_date:r}}` などの RFC 2822 出力が ja 環境で「月, 27 4月 2026 ...」となっていた。

`DateTimeImmutable::format()` を使う `Feedwright\Bindings\DateFormatter` を追加し、4 つの provider (Feed / Now / Post / PostRaw) の `wp_date` を差し替え。

Verification (locale=ja)

  • `{{now:r}}` → `Mon, 27 Apr 2026 21:08:20 +0900` ✓
  • `{{feed.last_build_date:r}}` → `Mon, 27 Apr 2026 21:08:20 +0900` ✓

Test plan

  • phpcs / phpunit unit / integration
  • 実機 wp eval で英語出力を確認

wp_date() / get_the_date() が D / M / l / F format を site locale に
翻訳するため、{{feed.last_build_date:r}} の出力が ja で
"月, 27 4月 2026 ..." になっていた。RFC 2822 / RFC 3339 は曜日/月名が
英語固定なので、PHP の date() 同等の挙動が必要。

DateTimeImmutable::format() でサイトタイムゾーンに変換しつつ常に英語名
を出す Feedwright\Bindings\DateFormatter を追加し、FeedProvider /
NowProvider / PostProvider / PostRawProvider の wp_date 呼び出しを
全てこちらに差し替えた。

実機確認 (locale=ja):
- {{now:r}}                 → Mon, 27 Apr 2026 21:08:20 +0900 ✓
- {{feed.last_build_date:r}} → Mon, 27 Apr 2026 21:08:20 +0900 ✓

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@mt8 mt8 merged commit eca306d into main Apr 27, 2026
7 checks passed
@mt8 mt8 deleted the issue/1 branch April 27, 2026 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feed.last_build_date:r などの日付バインディングが locale で曜日/月名を翻訳してしまう

1 participant