How to build a bilingual site

The bilingual site can be displayed in the selected language or automatically in the browser language. The second option makes it easy to reach the visitor, but the home page will have a smaller PageRank.

However, it should be understood that from the point of view of references, it is desirable to have different entry points for each language.

Show site in browser language using PHP

This code has been tested with the main browsers: Crome, Firefox, Opera, Safari.
File saved as index.php
In the example, the French page has the file name index-fr.php and the English page index-en.php
You can add as many languages as you like, following the same principle...

<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"</head>
<?php
                 
$lang = "en";
$serv = $_SERVER[HTTP_ACCEPT_LANGUAGE];
if($serv != false)
{                  
    $temp = explode(",",$serv);            
    $temp = strtolower(substr($temp[0]),0,2);            
    if($temp == "fr") $lang="fr";
}                  
?>

<iframe                  
<?php
    echo "src=\"index-$lang.php\"";
?>
 border=0 frameborder="no" RESIZE scrolling="YES" noresize >
</iframe>
<noframes>
<body>
    Frames requises.
</body>
</noframes>
</html>

If you install languages ​ ​ in subdirectories, for example, fr, en, etc., we will write without frames:

<?php
$lang="en";
$serv = $_SERVER[HTTP_ACCEPT_LANGUAGE];
if($serv != false)
{
$temp = explode(",",$serv);
$temp = strtolower(substr($temp[0],0,2));
if($temp == "fr") $lang="fr";
}
header("HTTP/1.1 302 Redirect");
header("location:https://www.iqlevsha.ru/$lang/");
?>

Page names

A homepage in a particular language does not necessarily have an index name, it can be given a meaningful name as conception.php for a French page and design.php for an English page, and this is good for a link.
In this case, the following lines will be changed in the code, replacing the example words with keywords selected depending on the site theme:

$lang = "design";
if($temp == "fr") $lang="conception";
echo "src=\"$lang.php\""; 

When you link to a site, you will give addresses: https://www.iqlevsha.ru/conception.php or https://www.iqlevsha.ru/design.php (replace iqlevsha.ru with the domain name of your site and replace the page names).

Conditional greeting redirection

To avoid losing PR, one solution is to place a page of a specific language as the homepage of the site, for example, the French homepage will be called index.php and it will contain PHP code that redirects visitors from other languages.
The disadvantage, if this page is important, which is often the case with a home page, is loading two pages when entering the site, for visitors of other languages.

The redirect code, depending on the browser language, is available in a zip file .

IP Forwarding

Some services, including Google itself, identify the user's origin from his IP address and automatically redirect him (and leave him no choice) to a site corresponding to his language. To install such a system, you will obviously need the ability to determine the origin of the user, and for this, the answers can be found in the article How to find out the country of the IP address.

Bilingual website and search engines

For selection from one of the previous processes, it is decisive: how the site will be visible by search engine algorithms.

The code for automatic browser redirection does not negatively affect PageRank pages other than the home page, unlike solutions that use the PHP "header" function, where search engine robots stop.
This is not an ideal solution, you lose the PR point on the home page, the problem seems inherent in a bilingual site, all solutions have drawbacks.

What Google recommends: The staff responsible for the algorithm and site optimization issues spoke at a roundtable with webmasters in October 2008, the bulk of the questions of which are repeated in Google's article "Answers to Webmasters."

Best for an English and French site, for example, in terms of search engines:

In fact, these three solutions are suitable for different cases.

Subareas

In this case, the use of subtopics will be the least relevant. Indeed, they are perceived by search engines as different sites, hence the separation of PageRank. Better site more than two small.
In fact, subdomains should only be used for a few users, each of whom has access to their own web space.

Country areas

Use different domains with the same disadvantage, but with the advantage of extension in relation to the language and a clearer URL for the audience.
The relative extension of the language, for example .fr, gives an advantage in positioning over local search.

Subdirectories

However, the presence of a larger site may outweigh the benefits of geolocation.
If the traffic on the site is not large enough to justify multiple domain names, then it is best to use subdirectories. Using a script to customize the language for the user, in my experience, is effective with the precautions specified in the article.