WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 3 years ago

#1762 closed enhancement (worksforme)

permalinks structure not i18n friendly

Reported by: anatman Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.1.2
Component: Permalinks Keywords: needs-patch
Focuses: Cc:

Description

The permalinks structure needs to get fields in the admin interface for $author_base, $search_base, $comments_base and $feed_base (all in classes.php), and for choosing the word used in paginating the site ("page" is hardcoded in $pageregex (classes.php) and in $page_modstring and $page_modregex (both in template-functions-links.php)), or these need to be internationalized.
The way it is harcoded now we have the english words "author", "comments", "feed" and "page" appearing in the permalinks.

Attachments (4)

customise_other_bases.diff (5.9 KB) - added by davidhouse 8 years ago.
gettext_perma.diff (1.0 KB) - added by ryan 8 years ago.
Apply gettext to permalink structure elements
1762.diff (2.5 KB) - added by mdawaffe 8 years ago.
reapply ryan's patch to current code. page_number_base (update: fix typo)
1762.redo.diff (16.6 KB) - added by rob1n 7 years ago.

Download all attachments as: .zip

Change History (40)

comment:1 markjaquith9 years ago

should this be customizable via an options interface or via plugins or via i18n? I can think of even English-speakers who would want to change this, like /author/ => /artist/ or /contributer/ or something else, so maybe these should be options on the permalink options page.

comment:2 anatman9 years ago

I agree completely with markjaquith, and his way would probably make it easier to code, wright?

comment:3 davidhouse8 years ago

  • Keywords bg|has-patch bg|squashed added
  • Owner changed from anonymous to davidhouse
  • Status changed from new to assigned

Attached patch allows for customisation of author, feed and comment feed bases. Although all these may not be necessary (and are thus superfluous options and thus harmful), I've left them in because

  1. They can always be removed by the committor (easier to remove than to add them back in if someone decided we need them).
  2. They might be useful for i18n (although we should allow .po/.mo files to customise these bases).

comment:4 ryan8 years ago

  • Milestone set to 1.6

I don't think these need to be provisionable. Simply marking them for translation should suffice. In WP_Rewrite init():

$this->author_base = trim(__('/author/'), '/');

Slashes are included in the translatable string for context and then stripped back out.

This way the strings show up in the po files for translation, and we don't have to clutter the permalink page with settings.

comment:5 anatman8 years ago

Please don't forget the word "page", which is hardcoded in $pageregex (classes.php) and in $page_modstring and $page_modregex (both in template-functions-links.php).
This word is quite important for translation because it is not an internet term like "feed", and it's meaning is the same as in other contexts.

ryan8 years ago

Apply gettext to permalink structure elements

comment:6 ryan8 years ago

Patch attached that applies gettext to permalink bases.

I'm wary of this approach since permalinks will change if the translation is changed, making them not so perma. Persisting them in the DB means adding provisioning UI for all of these fields, which is ugly and annoying. Both approaches have drawbacks. Still debating the best way to go.

comment:7 anatman8 years ago

Sorry to insist on this, but the hardcoding of the word "page" as noted above is bearing children: please take a look at the last version (0.41) of the Permalinks Redirect Plugin: http://fucoder.com/code/permalink-redirect/ (line 83). If in the future the word gets marked lots of people will have their permalinks breaking.
I just warned the plugin author.

comment:8 matt8 years ago

  • Milestone changed from 1.6 to 2.1

comment:9 pkirk8 years ago

I would like also to point out that the browser must support "strange" chars if they are in the translation on the permalinks. I don't think that a chinese char is supported in the address bar of the lastests browsers. Am I wrong?

comment:10 _ck_8 years ago

My apologies for being a newbie at how to do this but I would like to vote for these two patches and suggest they fold into the next 2.1 alpha (3?)

The diff is for an old build so I am unable to apply to any 2.x version except for manual editing.

They test and work well, at least on my (US) english site.

I would also suggest a better ticket title, the ability to change permalink structure for "author" etc. is not just a language issue and would be handy to many.

comment:11 _ck_8 years ago

Also note that the search_base can be potentially changed in 2.x

comment:12 mdawaffe8 years ago

1762.diff

  1. Ryan's patch reapplied to current trunk.
  2. Use page_number_base to keep track of /page/

Note: change things and you'll have to update your permalink structure.

mdawaffe8 years ago

reapply ryan's patch to current code. page_number_base (update: fix typo)

comment:13 matt7 years ago

  • Milestone changed from 2.1 to 2.2

comment:14 rob1n7 years ago

  • Keywords dev-feedback added; i18n bg|has-patch bg|squashed removed
  • Owner changed from davidhouse to rob1n
  • Status changed from assigned to new

I am +1 for making these options in Options > Permalinks. There are many times I wanted to change things like the feed base, the author base, or etc.

comment:15 rob1n7 years ago

  • Status changed from new to assigned

comment:16 rob1n7 years ago

  • Status changed from assigned to new

comment:17 rob1n7 years ago

  • Version changed from 1.5.2 to 2.1.2

comment:18 rob1n7 years ago

  • Status changed from new to assigned

comment:19 rob1n7 years ago

  • Type changed from defect to enhancement

comment:20 rob1n7 years ago

  • Milestone changed from 2.2 to 2.3

comment:21 rob1n7 years ago

  • Keywords has-patch needs-testing added; dev-feedback removed
  • Milestone changed from 2.3 to 2.2

comment:22 matt7 years ago

  • Milestone changed from 2.2 to 2.3

I think this is too broad for 2.2.

comment:23 rob1n7 years ago

  • Status changed from assigned to new

comment:24 rob1n7 years ago

  • Status changed from new to assigned

comment:25 rob1n7 years ago

  • Keywords needs-testing removed

Okay, that's what I have so far. Feeds+comment feeds aren't working. If you try to click on a link in Kubrick, at the bottom, you'll see what I mean.

I'll keep debugging this in the morning.

rob1n7 years ago

comment:26 rob1n7 years ago

  • Status changed from assigned to new

comment:27 westi7 years ago

  • Milestone changed from 2.3 to 2.4 (next)

This sounds like a very good idea.

Although I am not sure about overloading the Permalinks options page with extra options - maybe we should use filters instead and require a plugin to do the name changes?

Moving to 2.4 as it's too late to make a bit change like this to 2.3

comment:28 rob1n6 years ago

  • Owner rob1n deleted

comment:29 Nazgul6 years ago

  • Keywords needs-testing added

Is the attached patch still valid?

comment:30 ffemtcj6 years ago

  • Milestone changed from 2.5 to 2.6

comment:31 anatman5 years ago

  • Type changed from enhancement to defect

Bump. This has been here for 3 years now, and the problem is spreading: in 2.7RC1 we have the words "comment-page" hardcoded on line 1262, and "attachment" on line 1421 (in rewrite.php).

On the other hand tag_base is an option in the admin area (pemalinks) - which is not only nice, but makes sense.

All "bases" should be configurable via the admin interface.

comment:32 DD325 years ago

  • Component changed from Administration to Permalinks
  • Keywords needs-patch early added; has-patch needs-testing removed
  • Milestone changed from 2.9 to 2.8
  • Type changed from defect to enhancement

I agree that the permalinks should be translatable, and I'm closing #8312 as a duplicate of this.

Attached patch is stale, and probably needs to be reworked either way.

(Its an enhancement, not a defect)

comment:33 ryan5 years ago

  • Milestone changed from 2.8 to 2.9

comment:34 ryan5 years ago

  • Keywords early removed

comment:35 ryan5 years ago

  • Milestone changed from 2.9 to Future Release

Assigning to future release until a patch or direction manifests.

comment:36 nacin3 years ago

  • Milestone Future Release deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Pardon the necromancy of my reply but I'm pretty sure every rewrite base is now a WP_Rewrite property that can be modified by a plugin.

Note: See TracTickets for help on using tickets.