Php 如何通过语言的本地代码获取语言的方向?(RTL或LTR)
使用PHP内置函数和扩展(特别是intl)如何通过本地代码获得语言的方向?(RTL或LTR)Unicode中有一种称为“Unicode公共语言环境数据存储库”的东西,即CLDR,它正好提供了这段信息 您可以看到在CLDR中引入了哪些功能,包括脚本方向 请注意,脚本方向不仅仅是ltr或rtl,还有其他方向 然后,对于通过PHP访问,您可以查看google上搜索PHP和CLDR时出现的任何其他库Php 如何通过语言的本地代码获取语言的方向?(RTL或LTR),php,internationalization,locale,multilingual,intl,Php,Internationalization,Locale,Multilingual,Intl,使用PHP内置函数和扩展(特别是intl)如何通过本地代码获得语言的方向?(RTL或LTR)Unicode中有一种称为“Unicode公共语言环境数据存储库”的东西,即CLDR,它正好提供了这段信息 您可以看到在CLDR中引入了哪些功能,包括脚本方向 请注意,脚本方向不仅仅是ltr或rtl,还有其他方向 然后,对于通过PHP访问,您可以查看google上搜索PHP和CLDR时出现的任何其他库 /** * Retrieve the character order (right-to-left o
/**
* Retrieve the character order (right-to-left or left-to-right).
*
* @param string $locale The locale to use. If empty we'll use the default locale set in \Punic\Data
*
* @return string Return 'left-to-right' or 'right-to-left'
*/
public static function getCharacterOrder($locale = '')
{
$data = Data::get('layout', $locale);
return $data['characterOrder'];
}
谢谢你的评论。php Intl扩展基于CLDR,这个问题是想看看是否可以使用这个扩展从语言环境中获取方向。感谢您参考Punic。使用Punic,您可以调用:\Punic\Misc::getCharacterOrder();返回“从左到右”或“从右到左”