Drupal 7 translate blog page 'title' and 'URL alias' with i18n - drupal

I'm currently setting my Drupal 7 site up in an additional language using the i18n and variable translation.
My problem is that I cannot update the title of the blog page or the URL alias when I switch to the version for the other language. When I switch language my posts are translated but I cannot find where to change the titles of the page or the URL alias.
I'd like the routes to look something like this:
mydomain.com/news
mydomain.com/es/noticias

There are different kind of translations supported in Drupal. By default translation is made buy matching nodes in different languages togheter. And adding new translation actually means making new node and matching it with rest marked together.
But also you can translate fields. So in this case you don't have different nodes, but field values are translated. And if I remember well you can't translate all fields, i.e. you can't translate title and path since it's one node. Is this a case?
Update:
You would need to add "title" module:
https://www.drupal.org/project/title
Check out please this article:
https://www.drupal.org/node/1280910

Related

bilingual custom field labels with ACF (free version)

I am using custom fields (with the free version of ACF) to add additional, sometimes required, formatted content to the respective custom post type entries. I put together a little site-specific plugin which includes filters to add the custom fields to excerpt and content and puts them out, via a loop, as a list of:
{CUSTOM FIELD LABEL}: {CUSTOM FIELD VALUE}
The website should be available in English and German. Using the Sublanguage plugin, I could translate most of the website, but not the custom field labels.
From what I read on i18n/l10n and Wordpress, I understood that I should best use __() for the labels when creating the custom fields. Since custom field creation is realized by ACF plugin code, I assume I have to create the fields "myself" so that I can do multilingual labels using __(). I guess, I would then realize the actual translation of the fields with Loco Translate.
ACF offers a neat way to export my already existing ACF-created field groups, which provides me with the PHP code to create the fields "on my own". I put the ACF code inside a new function in my site-specific plugin and hooked it to the acf/init action. I did pretty much the same as described in this question, but nothing happens: When I trash the custom field groups within the ACF interface afterwards, no custom fields appear in the "new post" screen.
So basically, I am having one question that, depending on the answer, will spawn follow-up questions:
Is this how I should and can realize bi/multilingual custom field labels?
If no: How else would you implement bilingual custom field labels/names?
If yes: Am I hooking the function to the wrong action?
PS: I wasn't sure if this belongs here or in the WP StackExchange, since part of it is coding related and part of translation-logic-related. Please tell me if I should move it over to the other platform.
Alright,
I was able to solve most of this myself in the meantime:
I did not hook into the correct action. As it turns out, acf/init is only available in ACFv5 (pro), while the free edition is still in version 4.x. I hooked into init - et voilĂ : there are my field groups.
Using __() functions to declare my custom fields' labels, Loco Translate made it quite easy to translate the strings myself.
Conclusion
Apparently, my assumptions were correct - this is how to create internationalized custom field labels :) Nevertheless, I wasn't able to effectively translate the options of a checkbox field I am using, although Loco recognized the string and I provided a translation.
However....
The solution is far from perfect:
I am now using two plugins to translate as much as possible on the website.
Creating the ACF field groups "myself" through PHP code in my site-specific plugin, I needed to remove them from the admin UI. This means, that it's going to be difficult for any standard users to change anything about them in the future (which might of course be a feature as well :))

How to maintain specified fields invariate between linked custom posts with polylang

I've create some custom posts on my customized theme in wordpress, in which the polylang plugin is activated.
The translation works well, but the problem is that I need that specified contents remain the same between translated posts. With the normal posts you can deactivate the translation for the media type, but this will not apply for custom content type.
For example, if I got two languages, like English and Spanish, and I create a new custom english post:
[ENG POST]
TITLE
content1 *
content2
media1 *
media2
I'd want that on the spanish post some of the contents to be already populated with some of the contents that I've already written\uploaded in the english post (the ones with the "*" ), like:
[SP POST]
-empty-
content1
-empty-
media1
-empty-
For the custom posts I'm using the CMB2 plugin.
Is there an elegant way to do this?
Never done anything like that, but to my knowledge polylang creates another post and, when loading the new language form, completely reloads CMB2 fields, triggering all related events.
Getting in the right event and finding the original post id should allow you to set the previous values as default for the corresponding fields, but it's just theory, since I never really tried. Let me know if it works.
If you use CMB2's custom fields to create those parts of the custom post type content, here is the more or less elegant, straightforward way to achieve the goal.
Create the wpml-config.xml file (it's pretty self-explanatory)
<wpml-config>
<custom-fields>
<custom-field action="copy">cf_content_to_populate</custom-field>
<custom-field action="copy">cf_media_to_populate</custom-field>
<custom-field action="translate">cf_content_to_translate</custom-field>
<custom-field action="translate">cf_media_to_translate</custom-field>
</custom-fields>
</wpml-config>
and save it to the root directory of the theme you use.
cf_content_to_populate and cf_media_to_populate will be available all over the languages without translation, but cf_content_to_translate and cf_media_to_translate will require translation.
Using wpml-config.xml you can manage copying and/or translation of
specified custom fields;
specified custom post types;
specified taxonomies;
specified admin texts as custom plugin or custom theme options etc..
But you can't do this on per-post basis out-of-the-box.
Official Polylang documentation on The wpml-config.xml file.

WordPress non translatable content on a translatable custom post (via WPML)

I was recently implementing a custom post type in WordPress, and added WPML so I could translate it's title & content.
This post type (city) also has some custom metaboxes (metabox.io) like:
Coordinates
isFeatured
Address
etc...
The problem I'm facing now is these custom fields get stored against the post ID, and need to be added for each language (different languages are different post ID's). This is neither convenient or practical, given that I must now duplicate all the values from these fields in each language, and if there's a mistake one same city may have different coordinates in different languages.
My question is, what would be the best way to tackle this problem? How can I have one set of metadata relate to all the translations of a same post?
This way I only need to add it once for each city, and edit it in one place if needed.
Thanks,

Drupal: multilanguage.. looking for the right module to build multiple versions of the node

I have a multi-language website.
I want a module to add multiple version of my nodes and selecting the right one for each language of my website.
In other terms, for each node, I want to have more versions, a version for each language. I don't want to create new nodes, in order to avoid confusion for my customer.
I want to be able to fill the content for each language version of the same node.
If I'm not wrong, the core module Content Translation allows me to select for each node to which language interface belongs to, which is not what I want.
I saw the internationalization module, and it is good for translating taxonomy terms, and blocks, but it doesn't provide the functionality I want (multiple versions of each node).
thanks
Drupal.org has a lot of documentation related to multilingual sites.
http://drupal.org/node/324602
You may find that the Internationalization module will help you out. See this tutorial on setting up multilingual site using the Internationalization module.
#Patrick: CCK Translation makes it possible to have the labels and description of your CCK fields translated to different languages. The content that's stored inside those fields gets translated for the entire node, including all its fields using i18n module.
Hey! Thanks for reading my tutorial.
To properly translate CCK labels:
1 - activate CCK Translation module
2 - write the labels for your CCK fields in english
3 - Go to the "create new node" page. You're doing this to force Drupal to use the labels you just created. Visit the "create node" page in all your languages, so you force Drupal to try to show you the label in all the languages you have configured.
I know, this step is weird.
4 - Go to Admin -> Translate Interface (/admin/build/translate). Click on "search". Search your label in english, you'll see it appears several times, but marked as untranslated. Click on 'edit' for every string and translate them.
A bit clunky, but it works.

Drupal User Profile

One of my favourite sites at the moment is developmentseed.org. I really like what they do with there user profiles. How would you go about recreating it.
http://developmentseed.org/team seems to be a view of users/nodes
/team/eric-gundersen is a profile/node
"Posts by Eric Gundersen" block on the right of 2. seems to be a view. Is an argument being parsed to return content by Eric?
/blog/2009/oct/21/announcing-managing-news-pluggable-news-data-aggregator the user name links to the profile/node
Same link as above seems to be a block (teaser I guess).
Do you think there are using the defaults drupal module or a custom content type? How would you go about trying to implement something like this?
Thanks
Ryan
This seems to be a view of users with 3 fields: The avatar, the title of the user node (see 2) and the role name.
They're most likely using Content Profile.
In Views you can add an argument and specify that when no argument has been supplied (as is always the case for a block) a default value should be used. Among those default values you can select the user id from the current path. By adding a argument for the author of a node and specifying a default argument for it you can limit a node list to just the nodes created by that author.
I think this is built in functionality - the nice URL is probably an alias for user/123 created through PathAuto.
The block is probably a variant of 3 - the default argument is to take the id from the currently shown node instead and the teaser comes from the node linked to the user with the module described in 2.
So - to create something like that I would install Content Profile and then create some Views with arguments that has default values and with block displays. Does that help? :)
Of course, you can easily custom and theme the related User Profile page by including a user-profile.tpl.php file in your theme.

Resources