PHP+模板,我觉得是最好的办法.当然,客户端的输入,不可以多语言的.除非有智能化的翻译代码.

解决方案 »

  1.   

    好象....... google就是这样吧,你是什么语言过去,它就显示什么语言的版本给你
      

  2.   

    我觉得,如果单单是用模版来处理应该不是PHP的独有的,而且看不出来什么优势。可能是我PHP学的比较浅,我一直都作ASP,用模版处理是一种编程思想和语言没有什么关系。
    我倒是最近研究PHP的msn机器人的时候发现,PHP的底层功能十分诱人,在ASP中要借助COM来实现,而PHP可以直接用内在函数进行网络通信,支持打开网络的 Socket 链接。看来PHP在开源以后变得很强大了
      

  3.   

    google的强大是人所共知的,不知道php是如何提供的这中功能,看到那篇文章,真是觉得眼界大开,还有其他种种的功能,让我唏嘘不已!希望作者或者知情者能告诉下我如何让第三方的翻译变得轻而易举,当然其他的那些功能的实现方法说说也行啊!
      

  4.   

    phplet是不错,可惜在具体应用上还不成熟。
      

  5.   

    这个这个...缺乏重量级商业支持...感觉比较重要 没有ibm bea java也不会发展到今天
    另外,企业级应用不是想象得那么简单...看看j2ee再看看php...我想没必要非要跻身什么行列,ms得asp就是霸占了中低端市场阿 php的明天是美好的 但是,不能迷信php
    哦对了,其实asp也是无所不能 只是现在的asp程序员没几个会com得,实力大打折扣
      

  6.   

    多语言处理还是用模板之类的东西解决,也可以自己写一个函数,在你开发完之后,运行一下来查找替换,对于数据库中的字符,那是需要同时存储几个语种了。比如你的程序里面有朋友一词,那么开发的时候不要用朋友,你自己定义你的标签
    例如:
    <MYWEB:FRIEND>之类,之后,你用你的函数来查找这些标签,帮你翻译一下,替换成相应的字符....呵呵,上面是自己用的简陋的方法....
      

  7.   

    看来都对 gettext 不甚了了啊
      

  8.   

    blazingSnow(月光飞闪刀剑吻) 说的方法正是我现在在用的,或我跟你的方法类似。不过我看那篇文章真是说的神乎其神,真有那么强么。知道有那么强就应该知道怎么做到那么强。不至于知道它是神兵利器,缺不了解怎么运用,还一直拿它砍柴。岂不是笑话!
      

  9.   

    gettext有时候会出问题
    不知道为啥~~~
      

  10.   

    What is the best way to write an application for different languages?
    What is gettext used for?May 14th, 2000 20:22Nathan Wallace
    chuck
    I'd suggest gettext - there is gettext support in php 3.0.something (6?
    9?) and  later, and in php4 (compile --with-gettext). There's not much
    documentation right now, but it's pretty easy to use - you make the
    translations, set the locale, and then put _() around all your strings,
    and boom, it works. Fast, and also fairly standard.
      

  11.   

    Quick Primer on Using gettextPHP's gettext functions provide an interface to working with the GNU gettext utility. gettext is a GNU utility that helps programmers internationalize programs. A brief and somewhat inaccurate description of internationalization (often abbreviated I18N) is that it is the process of making software portable to languages and cultures other than the originating language(s) and culture(s). gettext helps this process by providing a set of tools to help manage the messages output by the software.Following is a brief overview of how to use gettext with a PHP script:1. Get and install a copy of gettext. (See http://www.gnu.org/ for more details.)2. Make sure PHP is built with gettext support (i.e., with --with-gettext on the ./configure command line).3. Develop your script/application, writing the messages in the language of your choice. Our sample application looks like this:<pre>
    <?
    // Write a small application to print "Good Morning!" in a variety of languages
    // Rather than hard-code the greetings, use gettext to manage the translations// Make an array
    // Use the ISO two-letter codes as keys
    // Use the language names as values
    $iso_codes = array (
        'en'=>'English',
        'fr'=>'French',
        'it'=>'Italian',
        'pt'=>'Portuguese',
        'es'=>'Spanish'
    );foreach ($iso_codes as $iso_code => $language) {
        // Set the LANGUAGE enviroment variable to the desired language
        putenv ('LANGUAGE='.$iso_code);        // Print out the language name and greeting
            // Note that the greeting is wrapped in a call to gettext
            printf ("<b>%12s:</b> %s\n", $language, gettext("Good morning!"));
    }
    ?>
    </pre>3. Extract the translatable strings with the xgettext utility. (xgettext is part of the gettext utilities and is not a PHP function.) A sample command line for the utility might look like this:xgettext \
        --extract-all \
        --c++ \
        --default-domain=greetings \
        --indent \
        --omit-header \
                 --sort-output \
        --width=76 \
        gettext.phpNoteYou may need different command line options than those noted above. For more information on xgettext, consult the gettext documentation or run xgettext --help.xgettext parses the specified file (in the previous example, gettext.php), looking for strings of characters. From the found strings, xgettext generates a file called greetings.po, which looks something like this:#: gettext.php:28
    #, c-format
    msgid   "<b>%12s:</b> %s\n"
    msgstr  ""#: gettext.php:28
    msgid   "Good morning!"
    msgstr  ""Note that xgettext was designed for parsing C and C++ files, and ignores single-quoted strings.Lines starting with # are comments.msgid contains the text of the original, untranslated message.msgstr contains the translated message.4. Open the .po file in your favorite text editor and remove any messages that you don't want translated. This would probably leave us with something like this:#: gettext.php:26
    msgid   "Good morning!"
    msgstr  ""5. Create a directory to store the tranlations.6. In the directory created in step 5, create one subdirectory for every language to which you will be translating. Name the directories for the ISO 639 language code - ar for Arabic, co for Corsican, en for English, and so on. See http://lcweb.loc.gov/standards/iso639-2/englangn.html for the codes.7. In each subdirectory, create a subdirectory named LC_MESSAGES.8. Place one copy of your .po file in every LC_MESSAGES directory.9. Have your translators translate the messages in the .po file in the appropriate directory.10. When the translations are ready, use the msgfmt utility to convert the .po files into the compact, binary format used by gettext. (msgfmt is another part of the gettext package, and is not a PHP function.) Basic syntax for converting the files is as follows:msgfmt -o output_file.mo input_file.poNoteYou may need different command line options than those noted above. For more information on msgfmt, consult the gettext documentation or run msgfmt --help.11. Modify your original script so that the gettext function knows where to find the translated versions:<pre>
    <?
    // Bind a domain to directory
    // Gettext uses domains to know what directories to 
    // search for translations to messages passed to gettext
    bindtextdomain ('greetings', './translations');// Set the current domain that gettext will use
    textdomain ('greetings');# Make an array
    # Use the ISO two-letter codes as keys
    # Use the language names as values
    $iso_codes = array (
        'en'=>'English',
        'fr'=>'French',
        'it'=>'Italian',
        'pt'=>'Portuguese',
        'es'=>'Spanish'
    );foreach ($iso_codes as $iso_code => $language) {
        # Set the LANGUAGE environment variable to the desired language
        putenv ('LANGUAGE='.$iso_code);        # Print out the language name and greeting
            # Filter the greeting through gettext
            printf ("<b>%12s:</b> %s\n", $language, _("Good morning!"));
    }
    ?>
    </pre>If you encounter troubles with these examples, read the gettext documentation. While gettext is simple to use, it takes a bit of time to get the hang of it.