dongtaochan0777 2011-07-06 05:51
浏览 51
已采纳

网站的多语言支持

While trying to modify eyeos install index page to support multi language using gettext method, i was unable to resolve an issue with the index page.

ISSUE:

The index page has 4 steps

It is possible to change the front page to the language we choose

but when i try to click next step it shows the default language rather than the choosen one

and also report an error as "Undefined index: submit in /var/www/html/install/index.php on line 78"

How can i resolve it...

the index.php file is

      <?php
        ob_start();
            if(!isset($_GET['step'])) 
            {
            $step = 'introduction';
           }  
           else 
           {
            $step = basename($_GET['step']);
           }
           require_once('steps/'.$step.'.php');
         echo '<?xml version="1.0" encoding="UTF-8" ?>';
           ?>
             <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml">
            <head>
     <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
             <link rel="stylesheet" type="text/css" media="all" href="style.css"/>
     <title>eyeOS 2 installation</title>
 </head>
 <body>

<form action="" method="post">
    <select name="language">
    <option value="en">English</option>
    <option value="es">Spanish</option>
    </select>
    <input type="submit" name="submit" value="change language"/>
</form>

        <div id="wrapper" class="wrapper">
            <div id="topbar" class="topbar">
                <img src="logo-eyeos.png" id="logo" class="logo" />
                <div id="logotext" class="logotext">
                    <? echo toptext(); ?>
                </div>
            </div>
            <span id="sidebar" class="sidebar">
                <ul class="sidelist">
                    <?php

                        if ($_POST['submit'])
                        {
                            bindtextdomain('messages', './');
                            textdomain('messages');

                            $lang=$_POST['language'];

                            if ($lang)
                            {

                                switch ($lang) 
                                {
                                    case 'es':
                                        putenv('LC_ALL=es_ES'); 
                                        setlocale(LC_ALL,'es_ES');
                                        break;
                                    case 'en':
                                    default:
                                        setlocale(LC_ALL,'en_GB');
                                        break;
                                }
                            }               


                        if($step == 'introduction') {
                            echo _('<li class="selected">Introduction</li>');
                        } else {
                            echo _('<li>Introduction</li>');
                        }

                        if($step == 'requirements') {
                            echo _('<li class="selected">Requirements</li>');
                        } else {
                            echo _('<li>Requirements</li>');
                        }
                        if($step == 'configuration') {
                            echo _('<li class="selected">Configuration</li>');
                        } else {
                            echo _('<li>Configuration</li>');
                        }

                        if($step == 'end') {
                            echo _('<li class="selected">End</li>');
                        } else {
                            echo _('<li>End</li>');
                        }
                        }  

                    ?>
                </ul>
            </span>
            <span id="content" class="content">
                  <?php getContent(); ?>
            </span>
        </div>
</body>

and i edited some line in messages.po file

Lines are

1."Content-Type: text/plain; charset=UTF-8 "

2.

: index.php:81

msgid "Introduction" msgstr "Introducción"

: index.php:83

msgid "

Introduction" msgstr "Introducción"

3.

: index.php:87

msgid "Requirements" msgstr "Requisitos"

: index.php:89

msgid "

Requirements" msgstr "Requisitos"

4.

: index.php:92

msgid "Configuration" msgstr "Configuración"

: index.php:94

msgid "

Configuration" msgstr "Configuración"

5.

: index.php:98

msgid "End" msgstr "Final"

: index.php:100

msgid "

End" msgstr "Final"

2.#: index.php:81 msgid "Introduction" msgstr "Introducción"

: index.php:83

msgid "

Introduction" msgstr "Introducción"
  • 写回答

1条回答 默认 最新

  • 普通网友 2011-07-06 08:58
    关注

    To fix the error you report, and also report an error as "Undefined index: submit in /var/www/html/install/index.php on line 78", change:

    if ($_POST['submit'])
    

    to:

    if (isset($_POST['submit']))
    

    2nd issue:

    I would add some debugging to your code to see what the result of $_POST['language'] is. Maybe you aren't catching the language properly in your switch

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)