File tree Expand file tree Collapse file tree 9 files changed +210
-0
lines changed Expand file tree Collapse file tree 9 files changed +210
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /*
3
+ TechPlayer, LLC.
4
+ https://www.techplayer.org
5
+ */
6
+ include ("lang/setlang.php " ); // Import language profile
7
+ ?>
8
+ <html>
9
+ <head>
10
+ <title><?php echo _ ('Gettext Multi-language website demo ' ); ?> </title>
11
+ </head>
12
+ <body>
13
+ <h1><?php echo _ ('Gettext Multi-language website demo ' ); ?> </h1>
14
+ <hr><br>
15
+ <p><font color="#ff0000"><?php echo _ ('Hello world ' ); ?> </font></p>
16
+ <h3><?php echo _ ('language selection ' ); ?> </h3>
17
+ <a href="?lang=zh-tw"><?php echo _ ('Traditional Chinese ' ); ?> </a> <a href="?lang=zh-cn"><?php echo _ ('Simplified Chinese ' ); ?> </a> <a href="?lang=en-us"><?php echo _ ('English ' ); ?> </a>
18
+ </body>
19
+ </html>
Original file line number Diff line number Diff line change
1
+ #, fuzzy
2
+ msgid ""
3
+ msgstr ""
4
+ "Project-Id-Version : Gettext Multi-language website demo\n "
5
+ "POT-Creation-Date : 2016-06-09 23:43+0800\n "
6
+ "PO-Revision-Date : 2016-06-09 17:40+0800\n "
7
+ "Last-Translator : 科技玩客 TechPlayer\n "
8
+ "Language-Team : 科技玩客 Techplayer <https.//www.techplayer.org>\n "
9
+ "Language : en_US\n "
10
+ "MIME-Version : 1.0\n "
11
+ "Content-Type : text/plain; charset=UTF-8\n "
12
+ "Content-Transfer-Encoding : 8bit\n "
13
+ "X-Generator : Poedit 1.8.8\n "
14
+ "X-Poedit-Basepath : ..\n "
15
+ "Plural-Forms : nplurals=2; plural=(n != 1);\n "
16
+ "X-Poedit-SearchPath-0 : index.php\n "
17
+
18
+ #: index.php:6 index.php:9
19
+ msgid "Gettext Multi-language website demo"
20
+ msgstr ""
21
+
22
+ #: index.php:11
23
+ msgid "Hello world"
24
+ msgstr ""
25
+
26
+ #: index.php:12
27
+ msgid "language selection"
28
+ msgstr ""
29
+
30
+ #: index.php:13
31
+ msgid "Traditional Chinese"
32
+ msgstr ""
33
+
34
+ #: index.php:13
35
+ msgid "Simplified Chinese"
36
+ msgstr ""
37
+
38
+ #: index.php:13
39
+ msgid "English"
40
+ msgstr ""
Original file line number Diff line number Diff line change
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version : Gettext Multi-language website demo\n "
4
+ "POT-Creation-Date : 2016-06-09 23:45+0800\n "
5
+ "PO-Revision-Date : 2016-06-09 23:45+0800\n "
6
+ "Last-Translator : 科技玩客 TechPlayer\n "
7
+ "Language-Team : 科技玩客 Techplayer <https.//www.techplayer.org>\n "
8
+ "Language : en_US\n "
9
+ "MIME-Version : 1.0\n "
10
+ "Content-Type : text/plain; charset=UTF-8\n "
11
+ "Content-Transfer-Encoding : 8bit\n "
12
+ "X-Generator : Poedit 1.8.8\n "
13
+ "X-Poedit-Basepath : ../../..\n "
14
+ "Plural-Forms : nplurals=2; plural=(n != 1);\n "
15
+ "X-Poedit-SearchPath-0 : index.php\n "
16
+
17
+ #: index.php:6 index.php:9
18
+ msgid "Gettext Multi-language website demo"
19
+ msgstr "Gettext Multi-language website demo"
20
+
21
+ #: index.php:11
22
+ msgid "Hello world"
23
+ msgstr "Hello world"
24
+
25
+ #: index.php:12
26
+ msgid "language selection"
27
+ msgstr "language selection"
28
+
29
+ #: index.php:13
30
+ msgid "Traditional Chinese"
31
+ msgstr "Traditional Chinese"
32
+
33
+ #: index.php:13
34
+ msgid "Simplified Chinese"
35
+ msgstr "Simplified Chinese"
36
+
37
+ #: index.php:13
38
+ msgid "English"
39
+ msgstr "English"
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /*
3
+ 科技玩客 TechPlayer
4
+ https://www.techplayer.org
5
+ */
6
+ preg_match ('/^([a-z\-]+)/i ' , $ _SERVER ['HTTP_ACCEPT_LANGUAGE ' ], $ matches ); // 分析 HTTP_ACCEPT_LANGUAGE 的屬性
7
+ $ lang = $ matches [1 ]; // 取第一語言設置
8
+ $ lang = strtolower ($ lang ); // 轉換為小寫
9
+ // 默認語言 & 類型
10
+ $ lang = $ lang ;
11
+ putenv ('LANG=en_US ' );
12
+ setlocale (LC_ALL , $ lang );
13
+
14
+ $ lang = isset ($ _GET ['lang ' ]) ? $ _GET ['lang ' ] : $ lang ;
15
+
16
+ if ('en-us ' == $ lang ) {
17
+ putenv ('LANG=en_US ' );
18
+ setlocale (LC_ALL , 'en_US ' );
19
+ } else if ('zh-tw ' == $ lang ) {
20
+ putenv ('LANG=zh_TW ' );
21
+ setlocale (LC_ALL , 'zh_TW ' ); // bsd use zh_TW.BIG5
22
+ header ('Content-type: text/html; charset=big5 ' );
23
+ } else if ('zh-cn ' == $ lang ) {
24
+ putenv ('LANG=zh_CN ' );
25
+ setlocale (LC_ALL , 'zh_CN ' ); // bsd use zh_CN.GBK
26
+ header ('Content-type: text/html; charset=gbk ' );
27
+ }
28
+
29
+ define ('PACKAGE ' , 'demo ' );
30
+
31
+ // gettext 設定
32
+ bindtextdomain (PACKAGE , 'lang ' ); // or $your_path/lang, ex: /var/www/test/lang
33
+ textdomain (PACKAGE );
34
+ ?>
Original file line number Diff line number Diff line change
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version : Gettext Multi-language website demo\n "
4
+ "POT-Creation-Date : 2016-06-09 23:44+0800\n "
5
+ "PO-Revision-Date : 2016-06-09 23:44+0800\n "
6
+ "Last-Translator : 科技玩客 TechPlayer\n "
7
+ "Language-Team : 科技玩客 Techplayer <https.//www.techplayer.org>\n "
8
+ "Language : zh_CN\n "
9
+ "MIME-Version : 1.0\n "
10
+ "Content-Type : text/plain; charset=UTF-8\n "
11
+ "Content-Transfer-Encoding : 8bit\n "
12
+ "X-Generator : Poedit 1.8.8\n "
13
+ "X-Poedit-Basepath : ../../..\n "
14
+ "Plural-Forms : nplurals=1; plural=0;\n "
15
+ "X-Poedit-SearchPath-0 : index.php\n "
16
+
17
+ #: index.php:6 index.php:9
18
+ msgid "Gettext Multi-language website demo"
19
+ msgstr "Gettext 多国语言网站演示"
20
+
21
+ #: index.php:11
22
+ msgid "Hello world"
23
+ msgstr "你好世界"
24
+
25
+ #: index.php:12
26
+ msgid "language selection"
27
+ msgstr "语言选择"
28
+
29
+ #: index.php:13
30
+ msgid "Traditional Chinese"
31
+ msgstr "繁体中文"
32
+
33
+ #: index.php:13
34
+ msgid "Simplified Chinese"
35
+ msgstr "简体中文"
36
+
37
+ #: index.php:13
38
+ msgid "English"
39
+ msgstr "英文"
Original file line number Diff line number Diff line change
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version : Gettext Multi-language website demo\n "
4
+ "POT-Creation-Date : 2016-06-09 23:43+0800\n "
5
+ "PO-Revision-Date : 2016-06-09 23:44+0800\n "
6
+ "Last-Translator : 科技玩客 TechPlayer\n "
7
+ "Language-Team : 科技玩客 Techplayer <https.//www.techplayer.org>\n "
8
+ "Language : zh_TW\n "
9
+ "MIME-Version : 1.0\n "
10
+ "Content-Type : text/plain; charset=UTF-8\n "
11
+ "Content-Transfer-Encoding : 8bit\n "
12
+ "X-Generator : Poedit 1.8.8\n "
13
+ "X-Poedit-Basepath : ../../..\n "
14
+ "Plural-Forms : nplurals=1; plural=0;\n "
15
+ "X-Poedit-SearchPath-0 : index.php\n "
16
+
17
+ #: index.php:6 index.php:9
18
+ msgid "Gettext Multi-language website demo"
19
+ msgstr "Gettext 多國語言網站演示"
20
+
21
+ #: index.php:11
22
+ msgid "Hello world"
23
+ msgstr "你好世界"
24
+
25
+ #: index.php:12
26
+ msgid "language selection"
27
+ msgstr "語言選擇"
28
+
29
+ #: index.php:13
30
+ msgid "Traditional Chinese"
31
+ msgstr "繁體中文"
32
+
33
+ #: index.php:13
34
+ msgid "Simplified Chinese"
35
+ msgstr "簡體中文"
36
+
37
+ #: index.php:13
38
+ msgid "English"
39
+ msgstr "英文"
You can’t perform that action at this time.
0 commit comments