---
title: "Translated URL Bases - PerfLocale"
description: "Translate the base of a post type, archive or taxonomy per language, such as /de/produkte/ for /product/, with one redirect from old bases and WP-CLI commands."
canonical: "https://perflocale.com/docs/url-bases/"
source: "https://perflocale.com/docs/url-bases/"
format: "markdown"
---
# Translated URL Bases

Give the fixed part of an address its own word in each language.

A URL base is the fixed part of a post type, archive or taxonomy address, such as `product` in `/product/chair/` or `product-category` in `/product-category/chairs/`. PerfLocale translates it per language, so the German product lives at `/de/produkte/chair/` instead of `/de/product/chair/`. The default language keeps the bases of **Settings → Permalinks**. A post’s or term’s own slug is translated separately, with [Translate Slugs](https://perflocale.com/docs/url-routing/).

## Translate a base

1.  Open **PerfLocale → Settings → URL & Routing** and click **URL Bases** in the links at the top of the tab. You need the `manage_options` capability.
2.  Each group lists its bases in a table with the columns **Base**, **On** and one column per language. **Content** holds the translatable post types with a base, their archives and the translatable taxonomies; with WooCommerce active, **WooCommerce** holds the product, product category, tag and brand bases and the bases of public attributes.
3.  Tick **Use the translated URL bases** (it is off until you do), type the word for a language, for example `produkte` in the German column of the product row, and press **Save Changes**.

After the save the notice reads “URL bases saved. Links and redirects use the new bases now.” An empty field uses the original base for that language, and the **On** box turns one base off without losing its values. The shop row says “Follows the translated Shop page.”: the shop address comes from the translated page, not from this screen. An attribute whose slug is not plain ASCII keeps its base in every language.

## Settings on the screen

| Setting | Default | What it does |
| --- | --- | --- |
| URL bases: Use the translated URL bases | Off | Tick it to use the bases you type. While it is off, nothing changes on your site: links use the bases of Settings → Permalinks, and translated addresses that were in use redirect to them. |
| Old addresses: Redirect old and other-language bases to the current base | On | When off, such addresses still show the page, with a canonical link to the current address. |
| Translate the URL bases of WooCommerce | On | Turns the whole WooCommerce group on or off. |

## Which values are accepted

Every value is checked before it is used. A refused value is named in the notice (“Not saved: _base_ in _language_ - _reason_”) and the other values of the same save are kept. A value is refused when:

-   it has more than 4 parts separated by `/`, a part is empty after cleaning (use letters, digits or `-`), or a part is longer than 200 bytes;
-   it is a language code, a word WordPress uses at the start of its own addresses, or starts with digits only (date archives use them);
-   it overlaps the URL base of another type or the base WordPress uses for this content type;
-   a published page or post, a category, a term or an author already uses that address (when the permalinks start with them), another plugin routes addresses under it, or another site of the network uses that path.

A site holds up to 200 URL bases and 64 languages. All values together are kept in one map of at most 64 KB, because every page request loads it; Site Health shows its size. A save that would make the map larger keeps the previous bases in use, without the values that save refused.

## Old addresses

When you change a base, the old one keeps working: `/de/product/chair/` answers with one permanent (301) redirect to `/de/produkte/chair/`, never a chain of hops. The same happens for a base of another language under this language’s prefix. The screen lists up to 5 old values per base and language under its field, each as “Old: _/base/_ (redirected)”.

**Forget old URLs**, below the form, stops these redirects for one base or for **All URL bases**, after you tick “Yes, these old addresses may show “not found” from now on”. Those addresses then show “not found”. A renamed language code and a term’s changed URL slug redirect too: see [Addresses that changed](https://perflocale.com/docs/url-routing/#changed-addresses).

## When a save does not go live at once

The notice says when the new bases wait. With no rewrite rules stored in WordPress, the previous bases stay in use until **Settings → Permalinks** is saved. When another update is running, or other settings changed at the same time, the new bases go live on the next admin page load. A form cut short by the server’s PHP `max_input_vars` is not saved, and the notice names the limit to raise.

## WP-CLI

```bash
wp perflocale url-bases list
wp perflocale url-bases set pt:product de produkte
wp perflocale url-bases set group:woocommerce --enabled=off
wp perflocale url-bases compile
wp perflocale url-bases forget --yes
```

`list` prints one row per base and language with its status (`--format=table|json|csv|yaml`). `set <key> <language> <value>` sets one value (an empty value clears it); `set <target> --enabled=on|off` turns `global`, `redirect`, `group:<id>` or one key on or off. `forget` takes an optional key. A key names the kind and the type: `pt:` for a post type, `pta:` for its archive, `tx:` for a taxonomy.

## Site Health

**Tools → Site Health** has the test **PerfLocale translated URL bases**: is every translated base in use, or is a value suspended, a route unchecked or an update pending, and how large is the map. See [Troubleshooting](https://perflocale.com/docs/troubleshooting/).

## Changing or deleting a language

**Changing a language’s code (its URL slug)** is refused while that language has translated URL bases, and while the new code has some. The notice reads “The language slug was not changed: this language has translated URL bases. Under Settings > URL & Routing > URL Bases, clear them and stop redirecting their old addresses, change the slug, then enter them again.” or, for the new code, “The language slug was not changed: the slug _xx_ still has translated URL bases. Choose another slug.” To go on:

1.  Under **Settings → URL & Routing → URL Bases**, empty that language’s fields and save.
2.  Use **Forget old URLs** for **All URL bases**, so their old addresses are not redirected any more.
3.  Change the code on the Languages screen.
4.  Enter the URL bases again under the new code.

Other reasons a code is not changed, each with a notice: “this language was changed somewhere else at the same time. Check it and try again.”; “the translated URL bases settings could not be read or saved just now. Try again.”; “the database did not save it. Try again.”; and “The language slug change could not be confirmed: the database did not answer. Reload the Languages list to see whether it was saved.” An empty code is not allowed: “The slug cannot be empty, so nothing was saved.”

**Deleting a language** deletes its translated URL bases with it. If the site’s database tables cannot undo a change in one step (very old table types), a language that has translated URL bases is not deleted until you clear them first. The notice reads “The language was not deleted: it has translated URL bases, and this site’s database cannot remove them together with the language. Under Settings > URL & Routing > URL Bases, clear them and stop redirecting their old addresses, then delete the language.” When the database does not answer, the notice reads “Deleting the language could not be confirmed: the database did not answer. Reload the Languages list to see whether it was deleted.”

## Networks, imports and moves

-   **Multisite:** each site has its own bases. A change refreshes the sites of the network in the background ([Updating and changing URL bases on a network](https://perflocale.com/docs/multisite/#network-updates)).
-   **Export and import:** an import from another site keeps this site’s own URL base history and registered bases unless you mark the site as a copy. URL base values for a language this site does not have are not imported, and the import shows how many ([Export & Import](https://perflocale.com/docs/export-import/#url-bases-import)).
-   **Switching from another plugin:** translated bases are not imported; enter them here after the switch ([What does not migrate](https://perflocale.com/docs/migration/#current-limits)).
-   **Deactivating or uninstalling:** SEO plugin indexes and sitemap caches keep the translated addresses; [re-index your SEO plugin](https://perflocale.com/docs/reliability/#seo-reindex) afterwards.

## For developers

-   [`perflocale/url_bases/value`](https://perflocale.com/docs/hooks/#perflocale-url-bases-value) sets a value from code; the row then reads “Set by code.”
-   [`perflocale/url_bases/enabled`](https://perflocale.com/docs/hooks/#perflocale-url-bases-enabled) returns the registered base instead of the translated value for one base and language.
-   [`perflocale/url_bases/providers`](https://perflocale.com/docs/hooks/#perflocale-url-bases-providers) adds a group of bases for your own plugin (`PerfLocale\Contract\UrlBasesProvider`).
-   [`perflocale/url_bases/max_map_bytes`](https://perflocale.com/docs/hooks/#perflocale-url-bases-max-map-bytes) changes the map size limit.
