Multi language sites and the index.php

1 replies
Hello

I am trying to run a site with several languages in wordpress. I have edited the index.php file (badly) to show the content in English.

I want to show the content in my other language (spanish).

Two things: I want to first write the content for the spanish site and put in in the Index.php- not sure WHERE I should put it.

Then I want the flag link to go to the spanish version of the homepage.

I have a plugin installed for this. qtranslate. I have followed the instuctions- such as 'edit html' for the homepage and "Use Query Mode (?lang=en)" on "URL Modification Mode".


I followed some instructions about how to do this but messed up my index.php!

Any idea if this is correct code and where it should go?

<?php if (qtrans_getLanguage()=="es"): ?>
<li><a href="<?php echo get_option('home'); ?>/?lang=es">Home ES</a></li>
<?php endif; ?>

I have
Use Query Mode (?lang=en)" on "URL Modification Mode" (wp--> admin--> settings--> languages--> Advanced Settings)


if (qtrans_getLanguage()=="es")
{ $lang_select = "";
$home_link = "inicio";}

elseif (qtrans_getLanguage()=="en") {
$lang_select = "/en";
$home_link = "home"; }

endif; ?>
#indexphp #language #multi #sites
  • Profile picture of the author Martyn Walker
    I'm going to stick my neck out and I might get slammed for it. I know Wordpress from a user point of view and I have created a few widgets for it but I have never bothered to learn the structure of it, I have never read a book or blog about coding with it, so chances are there is better advice out there. With that in mind this is what I would do if I were you:-

    1. Create your own index.php in the root folder
    2. Install two copies of Wordpress
    3. Create a cron to synchronise Theme and Plugin details

    A directory structure something like:-

    yourserver.com/blog/
    yourserver.com/blog/es/
    yourserver.com/blog/en/

    This way you get some flexibility. It gets easy to show the correct language based on their IP. Pseudo code in your index.php file would look like this:-

    if(ip == 'uk') {
    require_once('blog/en/index.php');
    } else if(ip == 'es') {
    require_once('blog/en/index.php');
    } else if(ip == 'cn') {
    require_once('blog/cn/index.php');
    } else {
    require_once('blog/en/index.php');
    }

    I threw in China just to show that it would be easy to expand with additional languages this way should the need arise.

    Using a cron to synchronise your design template and plugins would also need to update their configurations in the database too. I suspect this is a lot easier than it sounds.
    {{ DiscussionBoard.errors[1709700].message }}

Trending Topics