Skip to content

Help/About: Translate /random slug displayed in graphic. - #16278

Closed
peterwilsoncc wants to merge 9 commits into
WordPress:trunkfrom
peterwilsoncc:try/66202-i18n-random-image-svg
Closed

peterwilsoncc wants to merge 9 commits into
WordPress:trunkfrom
peterwilsoncc:try/66202-i18n-random-image-svg

Conversation

@peterwilsoncc

Copy link
Copy Markdown
Contributor

This modifies the graphic of the About page's feature image for random redirects to display the URL /random in the site's language.

The pill displaying the URL is removed from the image and replaced with a text element and an SVG of the link icon. In order to avoid the need to embed Inter with all the non-latin variations, the link is displayed with the font stack: Inter, Roboto, "Helvetica Neue", "Arial Nova", "Nimbus Sans", Arial, sans-serif;.

At the moment the pill is displayed as a link but I may end up removing this as I don't know that it's entirely necessary.

I've created a code bin for testing the display in various languages.

Trac ticket: https://core.trac.wordpress.org/ticket/66202

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Drafting the HTML/CSS for the translatable URL pill and its RTL styles, converting the design's pixel values to container query units, cross-browser and font-fallback testing with screenshots, and building the CodePen-style demo. The design decisions were mine. I reviewed and tested the final code.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

While this file is included in the PR, it is not merge ready. The image will be published on w.org's CDN.

Comment thread src/wp-admin/about.php Outdated
<img loading="lazy" src="https://s.w.org/images/core/7.2/about-feature-02.webp?ver=20261123" alt="" height="900" width="900" />
<div class="about__image about__image-random">
<img loading="lazy" src="<?php echo esc_url( admin_url( 'images/about-feature-02.webp?ver=20261126' ) ); ?>" alt="" height="900" width="900" />
<a class="about__image-random-url" href="<?php echo esc_url( home_url( '/?random' ) ); ?>">

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not convinced this needs to be a link.

I'm tempted to remove it and hide the entire block from screen readers as it doesn't provide any information that is not in the text.

Comment thread src/wp-admin/about.php
Comment on lines +100 to +101
$random_path = $wp_rewrite->using_permalinks() ? '/' . "\u{2060}" . _x( 'random', 'random content permalink base' ) : '/?random';
$random_url = $wp_rewrite->using_permalinks() ? home_url( user_trailingslashit( $wp_rewrite->root . $wp_rewrite->get_random_base() ) ) : home_url( '/?random' );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The displayed path uses _x() in the current user's locale, while $random_url uses get_random_base(), which returns the custom wp_random_base option if set, and otherwise the default translated into the site locale. With a different user locale or a custom base, the pill and link text can show /random while the link points to another slug. Using the base for both keeps them in sync:

Suggested change
$random_path = $wp_rewrite->using_permalinks() ? '/' . "\u{2060}" . _x( 'random', 'random content permalink base' ) : '/?random';
$random_url = $wp_rewrite->using_permalinks() ? home_url( user_trailingslashit( $wp_rewrite->root . $wp_rewrite->get_random_base() ) ) : home_url( '/?random' );
$random_base = $wp_rewrite->get_random_base();
$random_path = $wp_rewrite->using_permalinks() ? '/' . "\u{2060}" . $random_base : '/?random';
$random_url = $wp_rewrite->using_permalinks() ? home_url( user_trailingslashit( $wp_rewrite->root . $random_base ) ) : home_url( '/?random' );

The translator comment above would then no longer be needed, since the string is already translated in WP_Rewrite::get_random_base().

@peterwilsoncc
peterwilsoncc deleted the try/66202-i18n-random-image-svg branch November 30, 2026 21:13
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