That's excellent... Could I suggest you think of it a little differently though:
If you do a straight copy on creation of a new translation, the linked articles may eventually get out of sync.
Say I create a new translation from post 855 (English) which becomes post 900 (French).
The tags get copied from 855, and any tags which have French translations get put into the metadata of post 900.
(Note - when I say "tags", really it can apply to Categories, Taxonomies, and anything else with a translation)
The next day, I add/change/delete the tags from the English article.
French will still have the "old" tags.
I later translate a tag of 855 into French.
900's metadata, which *would* have had the French tag added if I had translated earlier, will not get updated with the now-translated tag.
If you create a new table containing the links between articles like this:
Lang1ID | Lang2ID | Lang3 ID | etc.
855 | 900 |
you could also add a filter for the_content (or perhaps the_tags) which:
- reads the tags on all linked articles (in this case, 855 and 900)
- checks if any tags exist in Lang1 that have a translation to Lang2
- permanently or temporarily adds the translated tag to the article's translation (selectable as an admin option)
Now, when I read the French article 900, *after* I've added some new tag translations, and removed some tags from article 855, I will *still* see matching tags in both.
This would also let you add a button where you could "sync" article tags (and categories, taxonomies, etc.) by looping through every post like this:
- foreach post_ID in the default language
- make an array translations of all it's translations
- make an array defaultLangTags of it's tag/tax/cat ID's in the default language
- foreach translationLang in translations
- foreach tag in defaultLangTags
- see if a translation exists in translationLang for that tag
- apply it to translationLang's post_ID
- (repeat for cat's, tax's, etc.)
This goes hand-in-hand with my other post about "flipping languages":
You will be able to click on French / English flags, and read the article in either language, and also see the same tags in both articles (assuming translations exist. Maybe as an option, you could show tags from the default language if the default language's article has a tag for which no translation exists.)
Currently, it sort of looks like there's an English article (post), and a French article - but they're separate articles.
Combined together, (this post and the flag post), Polylang could make it look like an article is "An Article" (unified), and all you have to do to read it in a different language, is click on the flag!
Anyways, my site is totally in development - not "production" at all, so I'm happy to put 0.6 on and play around and help you code it.
Email me at firstname.lastname@example.org if you'd like to discuss further.