Hi all,
I have some nodes with only the body field translatable.
My website have to show all nodes regardless the current language, in this way:
- If a node is translated: show the translated node for current language
- If a node is untranslated: show the source node, but with the localized url path
- If a node is language neutral: show the node with the localized url path
Now, I created a View of teaser, without any language filter: all works quite fine, in this way:
Suppose current language is ENGLISH:
- for case 1: ok, node (whose source lang is english and has a ita translation) is shown with path: mysite/en/node-1-alias
- for case 2: ok, node (whose source lang is english and doesn't have a ita translation) is shown with path: mysite/en/node-2-alias
- for case 3: ok, node (whose source lang is neutral) is shown with path: mysite/en/node-3-alias
Suppose current language is ITALIAN:
- for case 1: ok, node (whose source lang is english and has a ita translation) is shown with path: mysite/it/node-1-alias
- for case 2: mmmm, node (whose source lang is english and doesn't have a ita translation) is shown with path: mysite/it/node/[nid]
- for case 3: ok, node (whose source lang is neutral) is shown with path: mysite/it/node-3-alias
So, to better resolve last point 2, I'm asking if there is a way on node source creation (e.g. ENG) to anyway automatically create the path for untraslated content (-> ITA). In this way my untranslated content is visible with a consistent alias than the default "node/[nid]".
Alternatively, to reach the same result, please tell me the way (if exists) to automatically create the translation on a node (source) creation.
Thank you very much for helping me.
Comments
Comment #1
plachI am afraid there is no solution here that does not involve writing code. As you are rightly pointing out you need to:
Comment #2
mxtThank you for your answer, I'm actually trying to follow the first way: create a path alias for all languages when creating a node.
So here's what I did:
The code seems to works nice, please tell me if it's a good stuff or there are better ways to proceed.
The only thing I haven't resolved yet is deletion management: we have 2 cases here:
To resolve point 2 I've tried:
or:
But both doesn't work: alias of deleted translation is deleted too.
Any suggestion?
Thank you very much
Comment #3
plachSee
entity_translation_delete_confirm_submit(): you need a submit handler acting after it (pretty bad code there: we should implement the delete hook on behalf of path now that we have it).Comment #4
bforchhammer commented#1865176: Implement hook_entity_translation_delete() on behalf of path module
Comment #5
barami commentedI found the clean solution. http://drupal.org/node/1126548#comment-6509484
i think following instructions.
First, When created node, if drupal creates path by pathauto, it makes a only one path with selected language.
(if you posted node with english, only english path exists.)
I think if we make paths both und language path and source language path by pathauto, drupal will use source language path to indicate source language, and another languages will be indicated by und language path as fallback.
Now, entity_translation module only implements entity_translation_pathauto_alias_alter function for bulk update. (See hook_pathauto_alias_alter)
So.. We must modify that function to create path on node creation.
Comment #6
mxt@barami: this is very interesting: thank you very much!
I already thought to create a "parallel" language neutral path in any case, but abandoned the idea because I was not sure if this might have some kind of consequence in path/node management. Another reason is that different tokens for different path languages can't works with a unique UND path (with my partial solution above you can setup pathauto patterns with different tokens for every language).
But reading the link you have suggested (and the derivated ones) seems it could be a reasonable solution.
Comment #7.0
(not verified) commentedSmall mistake