PHP in English to switch the site is how to do

Source: Internet
Author: User
Tags add time
PHP in English to switch between the site is how to do?
Now want to do a foreign trade website, need Chinese and English two version, I want to ask, is to do two sites alone or just do one, then switch between Chinese and English?

------Solution--------------------
Multilingual Website Solution PHP

Objective:
Multilingual website Development, the focus is still in the solution of the problem between the language.
So how do we solve this problem? It's about three steps away:

1. Page Multi-lingual
2. Database Multi-language
3. Unified User Access language

1. Page Multi-lingual
Questions to consider:
A. When the user logs in, the characters are automatically recognized and the different language packs are called.
B. When the user switches different languages, call different language packs?
C. Add a multi-lingual directory structure?

Page multi-language is also the appearance of multi-language, here can adopt static language package way.
Design time should include the language directory, for different languages have a separate subdirectory.
such as English language/en, Simplified Chinese language/gb, Traditional Chinese language/b5 (can expand other languages)
Each directory contains a language version of each page. When you select a language version, you can call the appropriate version of the language pack.

Specific practices:
0. Using the JS language, identify the browser language, in the call to different language packs.

1.LANGUAGE/EN/GLOBAL.LN is a global language pack for the English version.

2.GLOBAL.LN content is:
$title = "中文版 webstie";
$charset = "UTF-8";

3.index.php Call:
Require_once ()
?>;
;
;
<title>; $title</title> <title>;</title>
;
;
;;
;

This enables the multilingual use of the page by extension.

2. Database Multi-language
The question of this consideration:
A. Multi-lingual data entry in the background?
B. How to save the content submitted by users under different versions?
C. Is it available in three language packs, or is it available in English and simplified, simplified and traditional by conversion?

Database multi-language is to achieve the unity of multi-language in the database. It is necessary to use Utf-8 unified coding.
Regardless of the language of the text, all unified use Utf-8 to store in the database. Use table fields to recognize
The text that belongs to the language version.

Specific:

A. Questions added to the background:

1. Add time to the background, you need to enter the multi-language. First set up a utf-8 code database, input english/simplified, simplified in the conversion to traditional,
It is then stored in the database in the Utf-8 encoding mode.

2. Establish a UTF-8-encoded table structure, importlanguage identify the language version
However, under a certain version, search for text that belongs to this version is displayed. Other text is not displayed.
DROP TABLE IF EXISTS ' zz_importer ';
CREATE TABLE IF not EXISTS ' Zz_importer ' (
' Importid ' int (one) not NULL auto_increment,
' Importtime ' date not NULL default ' 0000-00-00 ',
' Improtfile ' varchar (+) not NULL default ' ',
' importlanguage ' varchar (+) not NULL default '
PRIMARY KEY (' Importid ')
) Engine=myisam DEFAULT charset=uft-8;

3. Simplified conversion of the traditional.
Take advantage of PHP's iconv. This procedure is valid for Linux/unix and is not valid for Windows.
Iconv ("GB2312", "BIG5", $text);

4. Because, CharSet = "Utf-8", the data is in the Utf-8 encoding method exists,
When adding data, use EN/GB/BIG5 to identify the language version, respectively.
INSERT into ' Zz_importer ' VALUES (, ', ', ' en ');
INSERT into ' Zz_importer ' VALUES (, ' ', ' ', ' GB ');
INSERT into ' Zz_importer ' VALUES (, ' ', ' ', ' Big5 ');

B. For user-added issues:
1. Assume under Simplified Chinese. Users because the page header is UTF-8. The user's browser is encoded with Utf-8
Way to browse the page.

2. The added database itself exists in Utf-8 mode.

3. When adding data, use GB to identify the language version, respectively
INSERT into ' Zz_importer ' VALUES (, ' ', ' ', ' GB ');

C. For simplified and traditional is a separate or conversion issue

Available separately-more flexible than multilingual standards, no special requirements for ISPs.

Conversion delivery-commit speed is affected while the ISP provides ICONV function support.

3. Unified User Access language

A. Assume the user's Simplified Chinese version:
;
This is true for all language versions.

B. Call the language pack for LANGUAGE/GB.

C. The search database has a language field with gigabytes of data and displays

D. When the user submits the information, refer to the above database multi-language B issue.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.