如何使用PHP语言环境功能 [英] How to use PHP Locale functions

查看:52
本文介绍了如何使用PHP语言环境功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 windows vista 上运行 PHP .因此,我试图了解语言环境功能是如何工作的.我从

I'm running PHP on windows vista. So, I'm trying to get to know how locale functions work. I started with

setlocale(LC_ALL,$ locale) localeconv()

起初,它使用CLDR语言环境ID(我认为..,刚刚开始学习PHP语言环境),例如"en_US","en_UK"等,这在PHP文档示例中得到了证明.但是现在 setlocale() localeconv()仅适用于 $ locale 值,例如"English_United Kingdom.1252" "English_United States.1252" (我认为这是基于Windows的语言环境ID).

At first it worked with CLDR locale IDs(I think.., Just started learning PHP locales) like "en_US", "en_UK", etc, resulting as demonstrated in the PHP documentation examples. But now setlocale() and localeconv() only works with $locale values like "English_United Kingdom.1252" and "English_United States.1252" which I believe is windows based locale IDs.

所以当我这样做时:

var_dump(setlocale(LC_ALL, "en_US"));
var_dump(localeconv());

我得到这些结果:

boolean false

array (size=18)
  'decimal_point' => string '.' (length=1)
  'thousands_sep' => string '' (length=0)
  'int_curr_symbol' => string '' (length=0)
  'currency_symbol' => string '' (length=0)
  'mon_decimal_point' => string '' (length=0)
  'mon_thousands_sep' => string '' (length=0)
  'positive_sign' => string '' (length=0)
  'negative_sign' => string '' (length=0)
  'int_frac_digits' => int 127
  'frac_digits' => int 127
  'p_cs_precedes' => int 127
  'p_sep_by_space' => int 127
  'n_cs_precedes' => int 127
  'n_sep_by_space' => int 127
  'p_sign_posn' => int 127
  'n_sign_posn' => int 127
  'grouping' => 
    array (size=0)
      empty
  'mon_grouping' => 
    array (size=0)
      empty

如何使我的脚本响应CLDR语言环境ID?

How do I make my scripts respond to CLDR locale IDs?

推荐答案

setlocale()在您的情况下返回false.手册:

setlocale() returns false in your case. Manual:

返回新的当前语言环境;如果语言环境功能正常,则返回FALSE没有在您的平台上实现

Returns the new current locale, or FALSE if the locale functionality is not implemented on your platform

尝试使用以下之一:美国",美国",美国",美国"或美国"

Try to use one of: "usa", "america", "united states", "united-states", or "us"

http://msdn.microsoft.com/en-us/library/cdax410z%28v = vs.90%29.aspx

这篇关于如何使用PHP语言环境功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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