什么是Php gettext扩展的最简单的Php替代方案,可以由所有免费托管方式支持 [英] What's the simplest Php alternative to the Php gettext extension which can be supported by all kind of free hosting

查看:79
本文介绍了什么是Php gettext扩展的最简单的Php替代方案,可以由所有免费托管方式支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Zymic ,它的托管能力很好,但不支持 php gettext扩展名.我打算将来购买一些托管服务,但是从现在开始,我想要最简单的解决方案来替换 gettext 的功能,在这种情况下,我想显示不同的文本(英语,西班牙语,中文等),而无需修改文件太多(至少不必为每种语言创建经过拼合的文件).

I'm using Zymic, its a great hosting but it doesn't support the php gettext extension. I'm planning to buy some hosting in the future, but from now I want the simplest solution in order to replace the function of gettext, in this case I want to display different text (English, Spanish, Chinese, etc...) without modyfing the file too much (at least not having to create seaprated files for each language).

我尝试过类似的操作:

  <?php

    $lang = "";
    switch ($lang) {
        case "en":
            $lang = "Hello World";
            break;
        case "es":
            $lang = 'Hola Mundo';
            break;
    }

    ?>

    <div>
    <p><?php echo $lang;?></p>
    </div>

当我更改$lang变量时,它起作用.我是PHP的初学者,我想不出一种方法来在浏览器中进行更改(通过单击链接).

When I change the $lang variable it works. I'm a PHP beginner and I can't think of a way to make it change in the browser (by clicking a link).

或者有更好的方法吗?

推荐答案

我会说 此SO问题 . > 这个问题 我自己学到了Zend_translate.

I would say Zend_translate is the very best bet for internationalization these days. It's even better than gettext. See this SO Question for a number of arguments. This question was how I myself learned of Zend_translate.

对于您在问题中显示的简单任务来说,这有点多了,一开始可能需要花费一些工作来适应它,但是Zend组件有望为各种国际化问题提供很好的解决方案-不仅仅是翻译单词.还有多种不同的编号格式,时间格式,货币格式,时区...在对应用程序进行国际化时,都应加以注意.

It is a bit much for the simple task you show in your question, and it may be take a bit of work to get used to it in the beginning, but the Zend components promise very good solutions to all kinds of internationalization issues - which are more than just translating words. There are also different numbering formats, time formats, currency formats, time zones... all to be taken care of when internationalizing an application.

它不需要任何特定的扩展,您可以将Zend Framework的某些部分用作简单的库,无需遵循特定的应用程序结构或任何其他内容.

It doesn't require any specific extensions, and you can use parts of the Zend Framework as a simple library, there is no need to adhere to a specific application structure or anything.

这篇关于什么是Php gettext扩展的最简单的Php替代方案,可以由所有免费托管方式支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆