与intl库中的gettext()等效? [英] gettext() equivalent in Intl library?

查看:71
本文介绍了与intl库中的gettext()等效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种做i18n和l10n的方法.

I'm looking for a way to to do i18n and l10n.

我以前使用过gettext,这很好:我只是用不同的语言创建.mo文件,需要翻译的所有内容都使用这种表示法:

I've used gettext before and it was good: I would simply create .mo files in different languages and everything that needed to be translated would be in this notation:

echo __('string to be translated');

我知道PHP现在内置了Intl库,有人告诉我应该使用它而不是gettext().

I know that there is Intl library built into PHP now, and I've been told that I should use it instead of gettext().

在通读php.net上的关于Intl的所有内容之后,我发现它具有一些不错的功能,例如语言环境处理,字符串比较,数字格式等.

After reading through everything there is about Intl on php.net, I see that it has some nice features like locale handling, string comparison, number formatting, etc.

我不知道如何使用Intl库处理常规字符串到字符串的转换.有什么想法吗?

What I can't figure out is how I would handle regular string to string translation using Intl library. Any ideas?

推荐答案

您将使用gettext. Intl(如其下的ICU)用于l10n,不加载翻译.

You'd use gettext. Intl (like ICU underneath it) is for l10n, not loading translations.

这篇关于与intl库中的gettext()等效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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