Skip to content

feat(post-type): translate the generated archive view text - #597

Merged
ogorzalka merged 2 commits into
Pollora:developfrom
bale-dev:feature/archive-view-translations
Nov 10, 2026
Merged

ogorzalka merged 2 commits into
Pollora:developfrom
bale-dev:feature/archive-view-translations

Conversation

@bale-dev

@bale-dev bale-dev commented Nov 8, 2026

Copy link
Copy Markdown

The archive view generated by pollora:make:post-type has fixed English text for its pagination links and empty state, so that text stays in English on a translated site. The view now uses strings that WordPress and the post type already translate, so a theme doesn't need its own catalogue for them.

Changes

Text Before After
Link to newer posts Newer __('Newer posts')
Link to older posts Older __('Older posts')
Empty state Nothing published yet. get_queried_object()->labels->not_found

Impact

Only newly generated views change, because the command doesn't overwrite a view that already exists. Attributes, hooks, configuration and commands are unchanged, so no api-change label is needed.

How to test

vendor/bin/pest tests/Feature/PostType/PostTypeMakeViewsTest.php

Hard-coded English left every generated archive untranslated on a
non-English site. Take the pagination labels from strings WordPress
core already translates and the empty state from the post type's own
not_found label, so a theme needs no catalogue of its own.
@ogorzalka
ogorzalka changed the base branch from main to develop November 10, 2026 13:53
@ogorzalka

ogorzalka commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Thanks @bale-dev, this is a good follow-up to #583.

I changed the base branch of this pull request from main to develop. Features go through develop and reach main with a release; against main, your branch showed 31 files because it carries the history of develop. Against develop it is what you meant to send: the archive stub and its test, +15 −3.

I checked the change against WordPress 7.1.3: "Older posts" and "Newer posts" are strings of core's default domain, so they are translated without a catalogue; not_found is a post type label; and on a post type archive get_queried_object() returns the post type object, so ->labels->not_found is valid. The tests of the generator pass on an up-to-date develop.

Two small things, neither blocks the merge:

  • get_queried_object()->labels would fail if the view were ever used outside a post type archive. In the usual archive-{slug} case it can't happen, but get_post_type_object(get_post_type())->labels->not_found would not depend on the queried object. Your call.
  • There is no changelog line. I will add one when I prepare the release, so you don't need to.

@ogorzalka ogorzalka closed this Nov 10, 2026
@ogorzalka ogorzalka reopened this Nov 10, 2026
@ogorzalka ogorzalka changed the title Feature/archive view translations feat(post-type): translate the generated archive view text Nov 10, 2026
@ogorzalka
ogorzalka merged commit 6489ef6 into Pollora:develop Nov 10, 2026
19 of 20 checks passed
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.

2 participants