I'm still pretty new to all this so I might have overlooked something, but I can't seem to get the following to work:
1. Create a node in the default language (English), pathauto creates a user-friendly url path (/something/page-name/).
2. Add a translation (Swedish, Chinese, whatever) and keep the path generated for the default language (/se/something/page-name/ or /cn/something/page-name/). Instead I get a looooong url of url-encoded gibberish.
Right now I have to edit the translated node path manually every time, which wouldn't work in a situation where the site is handed off to a client.
site.com/something/page-name/
site.com/se/something/page-name/
is the pattern most large multilingual sites use (see apple.com for example).
Or am I missing something? Is there an easy solution?
cheers,
Erik
Comments
Comment #1
erikjohansson commentedI would love to have a [default-language-title-raw] or [se-title-raw] or [fr-title-raw] etc. token.
Comment #2
gregglesThat won't happen in pathauto.
That probably belongs on token module itself or in localization module.
If you are getting a lot of "weird" characters in the URL, I suggest trying the transliteration module. I imagine those are just non ASCII128 characters.
Comment #3
blueblade commentedHi erikjohansson,
Have you get pathauto to generate URLs like those you wrote here:
site.com/something/page-name/
site.com/se/something/page-name/
When I set a node language to the default language, I do get URLs like
site.com/something/page-name/
but when I am looking at the same page but in a different language, instead of getting
site.com/se/something/page-name/
I get
site.com/se/node/page-name/
Would you mind sharing with me how you get yours to work?
Many thanks!!
BB
Comment #4
mdorrell commentedI had to do this as well. I wrote a new token for the url_alias to use. I should note this was for Drupal 6. Here is my code for that:
Comment #5
Anonymous (not verified) commentedmdorrell
How do you use your code please?
[I think what I am experiencing is similar. If a node is created in one language and aliased, this alias is broken in another language.]
Comment #6
risca commentedI don't know if it could help some how, but with DRUPAL 6.1 this works. Maybe could help for inspiration.
Comment #7
dave reidThis token should be available in Drupal 7 with [node:source:url:alias].
Comment #9
clashar commentedPlease explain how to use this [node:source:url:alias].
I have "Pattern for all CV paths" (CV - is content type) as:
job/[current-user:profile-jobseeker:user:uid]/cv/[node:source:url:alias]
so when viewing the node in English I get this URL:
http://www.paris9.kz/emploi/job/1/cv
I want to have URL with "fr/" prefix for French smth like:
http://www.paris9.kz/emploi/fr/job/1/cv
but I get simply:
http://www.paris9.kz/emploi/fr/node/293/
if I tap URL manually "http://www.paris9.kz/emploi/fr/job/1/cv" then it's "Page not found".
I tried to run "update URL aliases", "update automatic nodetitles", but it didn't help.
what is the problem? should I change "Pattern for all CV paths" otherwise?
Comment #10
clashar commentedComment #11
dave reidThe token will only work if you are using the core Locale and Content Translation modules. When you translate a node from one language (let's say English) to French using the built-in translation UI, the token [node:source:url:alias] of the French node will return 'the-alias/of-my-english-node'.
Please do not continue to re-open long-fixed issues. Please file new support requests for any issues you have.
Comment #12
kwongkkt commentedThe [node:source:url:alias] does not work. Here are the steps to reproduce the problem.
1. brand new drupal site, with Locale and Content Translation enabled.
2. edit "Url alias" in admin/config/search/path/patterns
3. set "Default path pattern for Article (applies to all Article content types with blank patterns below)"
[node:title]4. Fill in "article" paths and leave blank for "English Article" (which is the source of everything)
[node:source:url:alias]5. go to create new article in "English" with title
New Article in english6. save and edit again, the automatic url now is
new-article-english7. now click on "translate" tab, it says
English (source) New Article in english8. click "add translation" for one other language, say "Chinese Traditional", using title
New Article in chinese traditional9. save it and now I expect the automatic alias filled in with
new-article-english10. but it actually is
node/12would anyone please suggest anything I missed?
Comment #13
P2Lnl commentedI seem to be having the exact same problem. The aliases only work for the default language, even though I have configured the language specific pattern. When manually typed it says the page cannot be found, meaning that this alias is broken or nonexistent. I assume many drupal 7 pathauto+internationalization users have this problem. Does anyone know where it comes from and how it can be fixed?
Comment #14
Cito commentedReplying to #7: [node:source:url:alias] does not exist (any more?) in D7, only [node:source:url] and [node:source:url:unaliased]. Both don't work for me, but [node:source:title] is useful.
Comment #15
dave reid[node:source:url:path] should work for you.
Comment #16
dave reidComment #17
dave reidRe-closing.
Comment #18
jreashor commentedIn case someone needs to do this in Drupal 7 (and since it lacks [node:source:url:alias]), I used the Custom Tokens module with the following PHP.
Comment #19
melissa.mcw commentedNot sure if people are still having this issue. I found that [node:source:url:path] does not, in fact, work. Instead I built a custom module, given that #18 was contingent on the Custom Tokens module being installed -- I did not want to go this route bc it was too impactful on the database.
The module code is :
<?php
/**
* @file
*custom_token module
*
* Provides a token to reference the url in the English language
*/
/**
* Implementation of hook_help()
*/
function MODULE_NAME_token_help($path, $arg) {
if ($path == 'admin/help#hid_custom_token') {
$txt = 'Provides a token to reference the url in the English language.';
return '
'. t($txt) .'
';
} // if help
} // function hid_custom_token_help
/**
* Implementation of hook_token_info
*/
function MODULE_NAME_token_token_info(){
$info['tokens']['node']['english-language-path'] = array(
'name' => t('HID Custom URL path alias'),
'description' => t('Token used to set URL path alias in English for regional languages.'),
);
return $info;
} // function hid_custom_token_token_info
/**
* Implementation of hook_tokens
*/
function MODULE_NAME_tokens($type, $tokens, array $data = array(), array $options = array()) {
if (isset($tokens['english-language-path'])) {
$tnid = $data['node']->tnid;
if (!empty($tnid)) {
$translations = translation_node_get_translations($tnid);
if (!empty($translations['en'])) {
$path = drupal_get_path_alias('node/' . $translations['en']->nid, 'en');
return array('[node:english-language-path]' => $path);
} // if has english translation
} // if has source node info
} // if right token is set
} // function hid_custom_token_tokens
It should also be said that once this token is implemented it will take the ENGLISH URL path.
Hope this helps someone, this is the only thing that seemed to work for my particular site.
Comment #20
Jinghan Wang commentedThanks for melissa.mcw's solution. It works on my site.
However, there is a small error said "Undefined index: node" and "Trying to get property of non-object". The module seems call the data variable twice, and the variable is different in each time. Not sure if it is the problem of my own. Hope some one can give an idea.
Thanks!
Comment #21
japerryThis appears still broken. #12 is exactly how you can reproduce this bug.
Will dive deeper through the debugger, but this is our steps:
First, configure the url aliases:
Default path pattern for Page (applies to all Page content types with blank patterns below) : "" (none, we customize each one)
"Pattern for all Catalan Page paths" : [node:source:url:path]
Next add content:
node/add/page, creating the source node.
add 'drupal-8.0' as the url alias for the source node (english)
save page. (Node id: 1234569)
Alias is: http://drupal.org/drupal-8.0
Next add translation
from the source node page just created:
-> add translation -> catalan
-> make sure automatic alias is checked (default)
-> Save page. The catalan page as Node id: 1234571
But the alias is: http://drupal.org/ca/node/1234569
=> It should be http://drupal.org/ca/drupal-8.0
Comment #22
jadhavdevendra commentedThis is still broken..!! :(
Comment #23
Jorge Navarro commentedThis works -> [node:source:title]
Comment #24
jaesperanza commented#23 works! Gracias, Jorge!
Comment #25
mably commented