情况
假设我们有以下课程:
<?php
class User {
const STATUS_NEW = 0;
const STATUS_DELETED = 1;
public static $aStatuses = array(
self::STATUS_NEW => 'New',
self::STATUS_DELETED => 'Deleted'
);
// ...
}
?>
问题
如何制作字符串New
并Deleted
准备好进行本地化(在示例中使用 gettext)?
可能的解决方案?
...
public static function getStatuses() {
return array(
self::STATUS_NEW => _('New'),
self::STATUS_DELETED => _('Deleted')
);
}
但不知何故,我觉得有一些更优雅的方式来做到这一点。