Home›Support›English Support›[Resolved] I want you to auto-translate the external files header and footer
[Resolved] I want you to auto-translate the external files header and footer
This thread is resolved. Here is a description of the problem and solution.
Problem:
I'm seeking assistance with loading header menu and footer from external files and ensuring their text content is automatically translated. Additionally, CSS styling for the translation switcher on index.php is not being applied.
Solution:
For the header menu, if it's a WordPress menu, you can follow WPML documentation for translating menus: https://wpml.org/documentation/getting-started-guide/translating-menus/. If it's not a standard WordPress menu, you'll need to wrap all text inside PHP code with the gettext method and then translate them using WPML String Translation.
For the footer, if it's widget-based, follow steps for translating widgets: https://wpml.org/documentation/getting-started-guide/translating-widgets/. If it's directly added to the theme, wrap text in PHP code with the gettext method, scan the theme for strings, and translate them using WPML String Translation.
To apply CSS to the translation switcher on index.php, wrap all direct text in PHP code with functions like __() and then scan the theme for strings. Translate them using WPML String Translation, and the CSS should apply automatically.
Loading header menu and footer in external file.
I want the text in these files to be automatically translated, is it possible? hidden link
Also, using the original theme, css is not applied to the translation switcher on index.php.
How do I apply the switcher's CSS to the switcher displayed in index.php? hidden link
The reason that it is not translated automatically is that the menu items are just single strings that do not have context, (For example they are not inside a sentence) that is why it is very hard for translation engines to predict the correct translation.
Please follow the steps mentioned in the documentation to translate the menus.
For the footer, I checked and I am not sure if it si using a widget system or it is something added directly to your theme.
If it uses WordPress `dashboard > Appearance > Widgest, then please follow the steps below to do the translation:
I've created the theme in original, and the header menu is not a regular WordPress menu, but I'm loading and using the header.php of an external file with index.php.
The footer menu also loads the footer.php of the external file, not the widget.
Fixed page headers and footers are loading header.php and footer.php as well as above。
How can I automatically translate the text contained in these?
I also want to auto-translate index.php, what should I do?
The switcher is not working at the moment.
Below is the source for index.php
---
<?php get_header(); ?>