This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Ricardo Alday 1 year ago.

Assigned support staff: Ricardo Alday.

Author Posts
October 6, 2018 at 12:35 am #2791957

andreasS-84

Hi there.

I have been struggling with translating my page for the past week now, as I've searched through countless of forum posts and YouTube videos in an attempt to solve this problem.

You see, I've developed a custom theme for my WordPress page, using (almost) only custom pages with custom content on it, that the user can change from the theme customizer. The specific code for the outputs are like this:

?php _e(get_theme_mod('latest_news_title')); ?>

and in the functions.php, the code is as follows:

$wp_customize->add_setting('latest_news_title', array(
'default' => _x('Tittel', 'Theme'),
'type' => 'theme_mod'
));

$wp_customize->add_control('latest_news_title', array(
'label' => __('Siste nyheter tittel', 'Theme'),
'section' => 'Nyheter',
'priority' => 3
));

So here is the tricky part. As far as I know, the user input on the customizer won't translate automatically. And for some strange reason, each time I the UK flag, indicating that I want to translate the current page in English, nothing happens except translation in my menu.

This is also complicating things further, since I have nearly only custom pages, I won't be able to navigate to a page like '/partners', that was '/partnere' (partners in Norwegian) before it was translated. So my question here is; would an option be to create a custom page for each page that I want translated as well?

I have also noticed that none of my page content gets translated, even when I have done the whole procedure of clicking Translate texts in admin screens » and selecting all the strings I want to be able to translate, and then finally translating them - without any luck. So here lies the question, even if I could in fact translate each custom page, I'm still stuck with a home.php, index.php and front-page.php that won't translate, and I can't create custom pages of these.

I do also have a couple of custom post types on my page, that does not get translated when I select language as well, after I've also done the actual translation for each post. This is really strange, and I can't seem to think of a way possible to make this translation go smooth. I've also though of making an extra input field for each customizer option that is the translation in English, so that the user can at least change the static content easily - instead of having to go through WPML. But I'm not sure if this is possible? I can't see that it will, due to the fact that my posts doesn't even translate?

Just a quick summary:

I have numerous custom pages 'page-whatever', 'page-whatever2' etc, that all echoes out values that has been submitted through the theme customizer. Due to the fact that I have this setup, upon page translation - that seem to only translate the menu, it gives me only invalid links, as I don't have a custom page set up for these translations like 'page-whatevertranslation'. Nor do I get my custom post types and my regular posts being translated on my very front page, even though I have translated it. What's the best solution for providing my client with the easiest translation for this kind of setup? All preferrably done in the customizer, with an extra field below that is the English translation (Norwegian is default).

Could someone please help me with this? It will be greatly appreciated.

October 8, 2018 at 8:46 pm #2797292

Ricardo Alday

Hi,

Thank you for contacting WPML support.

From your description, it seems you have a complicated setup for translations.
Using a template page as page-{slug}.php, does not work in translations because the page is selected by the slug, the different slug needs a different page.

You need to create pages template manually, one page for each slug or, if you prefer, you can create pages template with the comment at the top of the file. This way WPML can synchronize pages between languages and you will only need a one-page template. E.g.:

<?php
/**
 * Template Name: Example - About Us
 */
  
// content here

And the workflow would be as follows:
- create a page template that pulls data from Customizer options, name the template template-about.php (for example).
- Create a new empty page and assign it the template-about.php page template
- Translate the page and use the same page template in the translation
- Translate Customizer data in WPML -> String Translation -> translate

That's it. The pages should the content in the correct language.

However, the strings from the Customizer will still have to be translated through WPML -> String Translation -> translate text in admin screens, not the most user-friendly approach but it will do.

You can use a similar page template approach for your homepage.

Hope that help,
Ricardo

The topic ‘[Closed] Can't translate any content except menu’ is closed to new replies.