文档
Welcome! 安装(Installation) 示例列表(List of examples) 依赖注入与服务定位器(Dependency Injection/Service Location) MVC 架构(The MVC Architecture) 使用控制器(Using Controllers) 使用模型(Working with Models) 模型元数据(Models Meta-Data) 事务管理(Model Transactions) Phalcon 查询语言(Phalcon Query Language (PHQL)) 缓存对象关系映射(Caching in the ORM) 对象文档映射 ODM (Object-Document Mapper) 使用视图(Using Views) 视图助手(View Helpers) 资源文件管理(Assets Management) Volt 模版引擎(Volt: Template Engine) MVC 应用(MVC Applications) 路由(Routing) 调度控制器(Dispatching Controllers) 微应用(Micro Applications) 使用命名空间(Working with Namespaces) 事件管理器(Events Manager) 请求环境 (Request Environment) 返回响应(Returning Responses) Cookie 管理(Cookies Management) 生成 URL 和 路径(Generating URLs and Paths) 闪存消息(Flashing Messages) 使用 Session 存储数据(Storing data in Session) 过滤与清理(Filtering and Sanitizing) 上下文编码(Contextual Escaping) 验证(Validation) 表单(Forms) 读取配置(Reading Configurations) 分页(Pagination) 使用缓存提高性能(Improving Performance with Cache) 安全(Security) 加密/解密( Encryption/Decryption ) 访问控制列表 ACL(Access Control Lists ACL) 多语言支持(Multi-lingual Support) 通用类加载器 ( Universal Class Loader ) 日志记录(Logging) 注释解析器(Annotations Parser) 命令行应用(Command Line Applications) 队列(Queueing) 数据库抽象层(Database Abstraction Layer) 国际化(Internationalization) 数据库迁移(Database Migrations) 调试应用程序(Debugging Applications) Phalcon 开发工具(Phalcon Developer Tools) 提高性能:下一步该做什么?(Increasing Performance: What's next?) 单元测试(Unit testing) 授权(License)
教程

发布于 2015-08-21 15:19:44 | 416 次阅读 | 评论: 98 | 来源: 网络整理

国际化(Internationalization)

Phalcon is written in C as an extension for PHP. There is a PECL extension that offers internationalization functions to PHP applications called intl. Starting from PHP 5.4/5.5 this extension is bundled with PHP. Its documentation can be found in the pages of the official PHP manual.

Phalcon does not offer this functionality, since creating such a component would be replicating existing code.

In the examples below, we will show you how to implement the intl extension’s functionality into Phalcon powered applications.

This guide is not intended to be a complete documentation of the intl extension. Please visit its the documentation of the extension for a reference.

匹配最佳的区域设置(Find out best available Locale)

There are several ways to find out the best available locale using intl. One of them is to check the HTTP “Accept-Language” header:

<?php

$locale = Locale::acceptFromHttp($_SERVER["HTTP_ACCEPT_LANGUAGE"]);

// Locale could be something like "en_GB" or "en"
echo $locale;

Below method returns a locale identified. It is used to get language, culture, or regionally-specific behavior from the Locale API.

Examples of identifiers include:

  • en-US (English, United States)
  • ru-RU (Russian, Russia)
  • zh-Hant-TW (Chinese, Traditional Script, Taiwan)
  • fr-CA, fr-FR (French for Canada and France respectively)

基于区域设置格式化信息(Formatting messages based on Locale)

Part of creating a localized application is to produce concatenated, language-neutral messages. The MessageFormatter allows for the production of those messages.

Printing numbers formatted based on some locale:

<?php

// Prints € 4 560
$formatter = new MessageFormatter("fr_FR", "€ {0, number, integer}");
echo $formatter->format(array(4560));

// Prints USD$ 4,560.5
$formatter = new MessageFormatter("en_US", "USD$ {0, number}");
echo $formatter->format(array(4560.50));

// Prints ARS$ 1.250,25
$formatter = new MessageFormatter("es_AR", "ARS$ {0, number}");
echo $formatter->format(array(1250.25));

Message formatting using time and date patterns:

<?php

// Setting parameters
$time   = time();
$values = array(7, $time, $time);

// Prints "At 3:50:31 PM on Apr 19, 2015, there was a disturbance on planet 7."
$pattern   = "At {1, time} on {1, date}, there was a disturbance on planet {0, number}.";
$formatter = new MessageFormatter("en_US", $pattern);
echo $formatter->format($values);

// Prints "À 15:53:01 le 19 avr. 2015, il y avait une perturbation sur la planète 7."
$pattern   = "À {1, time} le {1, date}, il y avait une perturbation sur la planète {0, number}.";
$formatter = new MessageFormatter("fr_FR", $pattern);
echo $formatter->format($values);

特定区域设置的字符串比较(Locale-Sensitive comparison)

The Collator class provides string comparison capability with support for appropriate locale-sensitive sort orderings. Check the examples below on the usage of this class:

<?php

// Create a collator using Spanish locale
$collator = new Collator("es");

// Returns that the strings are equal, in spite of the emphasis on the "o"
$collator->setStrength(Collator::PRIMARY);
var_dump($collator->compare("una canción", "una cancion"));

// Returns that the strings are not equal
$collator->setStrength(Collator::DEFAULT_VALUE);
var_dump($collator->compare("una canción", "una cancion"));

音译(Transliteration)

Transliterator provides transliteration of strings:

<?php

$id = "Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();";
$transliterator = Transliterator::create($id);

$string = "garçon-étudiant-où-L'école";
echo $transliterator->transliterate($string); // garconetudiantoulecole
最新网友评论  共有(98)条评论 发布评论 返回顶部
PHPERZ网友 发布于2024-10-26 03:01:45
@@dhI1W
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:45
1����%2527%2522
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:45
1'"
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:45
1'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:42
1*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:39
V0F00eoH')) OR 479=(SELECT 479 FROM PG_SLEEP(15))--
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:37
t7zRpyBj') OR 535=(SELECT 535 FROM PG_SLEEP(15))--
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:32
JtvhMuso' OR 125=(SELECT 125 FROM PG_SLEEP(15))--
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:30
-1)) OR 807=(SELECT 807 FROM PG_SLEEP(15))--
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:26
-5) OR 948=(SELECT 948 FROM PG_SLEEP(15))--
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:24
-5 OR 958=(SELECT 958 FROM PG_SLEEP(15))--
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:21
U2X0hfj3'; waitfor delay '0:0:15' --
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:19
1 waitfor delay '0:0:15' --
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:15
-1); waitfor delay '0:0:15' --
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:13
-1; waitfor delay '0:0:15' --
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:11
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:09
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:07
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:05
if(now()=sysdate(),sleep(15),0)
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:03
-1" OR 2+341-341-1=0+0+0+1 --
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:03
-1' OR 2+776-776-1=0+0+0+1 or 'eEG8m3Uy'='
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:02
-1' OR 2+473-473-1=0+0+0+1 --
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:02
-1 OR 2+676-676-1=0+0+0+1
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:02
-1 OR 2+313-313-1=0+0+0+1 --
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:02
M7N3ASi0
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:01:00
1
支持(0)  反对(0)  回复
PHPERZ网友 发布于2024-10-26 03:00:58
1
支持(0)  反对(0)  回复
Kevin 发布于2021-02-23 17:29:50
http://ssb100kv2-form-260818.ssr.ias-lab.de
支持(28)  反对(27)  回复
Kevin 发布于2021-01-24 01:08:47
http://ssb100k-form-8534134.ssr.ias-lab.de
支持(1)  反对(1)  回复
e 发布于2018-08-01 02:03:04
不详细,有什么用
  • 2楼  MmzHrrdb 回复于2024-10-26 02:55:08
    1
  • 3楼  MmzHrrdb 回复于2024-10-26 02:55:08
    1
  • 4楼  MmzHrrdb 回复于2024-10-26 02:55:32
    1
  • 5楼  MmzHrrdb 回复于2024-10-26 02:55:32
    1
  • 6楼  MmzHrrdb 回复于2024-10-26 02:55:32
    1
  • 7楼  MmzHrrdb 回复于2024-10-26 02:56:28
    1
  • 8楼  MmzHrrdb 回复于2024-10-26 02:56:28
    1
  • 9楼  MmzHrrdb 回复于2024-10-26 02:56:28
    1
  • 10楼  MmzHrrdb 回复于2024-10-26 02:57:05
    1
  • 11楼  MmzHrrdb 回复于2024-10-26 02:57:05
    1
  • 12楼  MmzHrrdb 回复于2024-10-26 02:57:05
    1
  • 13楼  MmzHrrdb 回复于2024-10-26 02:58:02
    1
  • 14楼  MmzHrrdb 回复于2024-10-26 02:58:02
    1
  • 15楼  MmzHrrdb 回复于2024-10-26 02:58:02
    1
  • 16楼  MmzHrrdb 回复于2024-10-26 02:58:09
    1
  • 17楼  MmzHrrdb 回复于2024-10-26 02:58:11
    1
  • 18楼  MmzHrrdb 回复于2024-10-26 02:58:13
    1
  • 19楼  MmzHrrdb 回复于2024-10-26 02:58:13
    1
  • 20楼  MmzHrrdb 回复于2024-10-26 02:58:37
    1
  • 21楼  MmzHrrdb 回复于2024-10-26 02:58:39
    1
  • 22楼  MmzHrrdb 回复于2024-10-26 02:59:19
    1
  • 23楼  MmzHrrdb 回复于2024-10-26 02:59:21
    1
  • 24楼  o6UCKFsz 回复于2024-10-26 02:59:23
    1
  • 25楼  -1 OR 2+82-82-1=0+0+0+1 -- 回复于2024-10-26 02:59:23
    1
  • 26楼  -1 OR 2+338-338-1=0+0+0+1 回复于2024-10-26 02:59:23
    1
  • 27楼  -1' OR 2+90-90-1=0+0+0+1 -- 回复于2024-10-26 02:59:23
    1
  • 28楼  -1' OR 2+255-255-1=0+0+0+1 or 'K1v60BrM'=' 回复于2024-10-26 02:59:24
    1
  • 29楼  -1" OR 2+758-758-1=0+0+0+1 -- 回复于2024-10-26 02:59:24
    1
  • 30楼  if(now()=sysdate(),sleep(15),0) 回复于2024-10-26 02:59:26
    1
  • 31楼  0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z 回复于2024-10-26 02:59:29
    1
  • 32楼  0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z 回复于2024-10-26 02:59:31
    1
  • 33楼  (select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/ 回复于2024-10-26 02:59:33
    1
  • 34楼  1 waitfor delay '0:0:15' -- 回复于2024-10-26 02:59:38
    1
  • 35楼  DfGX0vRo'; waitfor delay '0:0:15' -- 回复于2024-10-26 02:59:42
    1
  • 36楼  R9dRwZ4X' OR 452=(SELECT 452 FROM PG_SLEEP(15))-- 回复于2024-10-26 02:59:45
    1
  • 37楼  AINPWpcE') OR 272=(SELECT 272 FROM PG_SLEEP(15))-- 回复于2024-10-26 02:59:49
    1
  • 38楼  aZ0AsDqa')) OR 196=(SELECT 196 FROM PG_SLEEP(15))-- 回复于2024-10-26 02:59:53
    1
  • 39楼  MmzHrrdb'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||' 回复于2024-10-26 02:59:56
    1
  • 40楼  1'" 回复于2024-10-26 02:59:56
    1
  • 41楼  1����%2527%2522 回复于2024-10-26 02:59:56
    1
  • 42楼  @@IOzqP 回复于2024-10-26 02:59:56
    1
  • 43楼  MmzHrrdb 回复于2024-10-26 02:59:58
    1
  • 44楼  MmzHrrdb 回复于2024-10-26 03:00:01
    1
  • 45楼  MmzHrrdb 回复于2024-10-26 03:00:04
    WNng0Xqi
  • 46楼  MmzHrrdb 回复于2024-10-26 03:00:04
    -1 OR 2+837-837-1=0+0+0+1 --
  • 47楼  MmzHrrdb 回复于2024-10-26 03:00:04
    -1 OR 2+365-365-1=0+0+0+1
  • 48楼  MmzHrrdb 回复于2024-10-26 03:00:05
    -1' OR 2+717-717-1=0+0+0+1 --
  • 49楼  MmzHrrdb 回复于2024-10-26 03:00:05
    -1' OR 2+693-693-1=0+0+0+1 or 'VLRJhHpP'='
  • 50楼  MmzHrrdb 回复于2024-10-26 03:00:05
    -1" OR 2+124-124-1=0+0+0+1 --
  • 51楼  MmzHrrdb 回复于2024-10-26 03:00:07
    if(now()=sysdate(),sleep(15),0)
  • 52楼  MmzHrrdb 回复于2024-10-26 03:00:10
    0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
  • 53楼  MmzHrrdb 回复于2024-10-26 03:00:16
    0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
  • 54楼  MmzHrrdb 回复于2024-10-26 03:00:18
    (select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
  • 55楼  MmzHrrdb 回复于2024-10-26 03:00:20
    -1; waitfor delay '0:0:15' --
  • 56楼  MmzHrrdb 回复于2024-10-26 03:00:22
    -1); waitfor delay '0:0:15' --
  • 57楼  MmzHrrdb 回复于2024-10-26 03:00:25
    1 waitfor delay '0:0:15' --
  • 58楼  MmzHrrdb 回复于2024-10-26 03:00:27
    npH1FDWN'; waitfor delay '0:0:15' --
  • 59楼  MmzHrrdb 回复于2024-10-26 03:00:29
    -5 OR 412=(SELECT 412 FROM PG_SLEEP(15))--
  • 60楼  MmzHrrdb 回复于2024-10-26 03:00:31
    -5) OR 464=(SELECT 464 FROM PG_SLEEP(15))--
  • 61楼  MmzHrrdb 回复于2024-10-26 03:00:33
    -1)) OR 785=(SELECT 785 FROM PG_SLEEP(15))--
  • 62楼  MmzHrrdb 回复于2024-10-26 03:00:35
    k19BSlpr' OR 14=(SELECT 14 FROM PG_SLEEP(15))--
  • 63楼  MmzHrrdb 回复于2024-10-26 03:00:37
    4tYN3BXT') OR 831=(SELECT 831 FROM PG_SLEEP(15))--
  • 64楼  MmzHrrdb 回复于2024-10-26 03:00:39
    ninkOPwz')) OR 261=(SELECT 261 FROM PG_SLEEP(15))--
  • 65楼  MmzHrrdb 回复于2024-10-26 03:00:41
    1*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
  • 66楼  MmzHrrdb 回复于2024-10-26 03:00:43
    1'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
  • 67楼  MmzHrrdb 回复于2024-10-26 03:00:43
    1'"
  • 68楼  MmzHrrdb 回复于2024-10-26 03:00:44
    1����%2527%2522
  • 69楼  MmzHrrdb 回复于2024-10-26 03:00:44
    @@BukQO
  • 支持(2)  反对(1)  回复

    Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务