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

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

报告相同问题?

悬赏问题

  • ¥50 求解vmware的网络模式问题
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳
  • ¥15 springboot 3.0 实现Security 6.x版本集成
  • ¥15 PHP-8.1 镜像无法用dockerfile里的CMD命令启动 只能进入容器启动,如何解决?(操作系统-ubuntu)
  • ¥30 请帮我解决一下下面六个代码
  • ¥15 关于资源监视工具的e-care有知道的嘛
  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?