dongwei3120 2015-04-20 08:06
浏览 49

PHP setlocale / gettext和intl扩展一起工作?

I have the php intl extension installed for normalizing strings and to retrieve language names and country names for the selected language. I have 2 select boxes, one to select a country where the person currently is and to select a language for the site. Now I have used the function _() to translate the site.

Now when I do ./locale -a to see all supported languages and when I match this with the locales supported by the intl extension (intlcal_get_available_locales()) there are a lot of differences. I have tried to map these and this kinda works, but I can't believe that this is the preferred method to do this.

I am struggling with this for a very long time. How can I best solve this. What am I doing wrong? Is there a best way to do localization and translation.

For every possible country in ISO 3166 I have mapped the locales from the intl extension to it. For countries which aren't listed in the intl extension I have mapped them myself. For example country code AQ I have mapped it to nb_NO. I also have tried to map a primary locale to every country which has multiple locales.

The following problems I came across are:

  • If I want to support the arabic language (ar), there is nog ar_AR, so I have to use for example ar_AE to use in setlocale, otherwise I can't set the translations there for ar.

  • The locale mn_MN is supported in setlocale, but it isn't supported in the intl extension.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c