I18n 组件用于您的应用程序消息国际化。

v1.3.0 2019-10-12 16:26 UTC

This package is auto-updated.

Last update: 2024-09-13 04:21:49 UTC


README

version MIT License

I18n 组件用于您的应用程序消息国际化。

安装

composer require flextype-components/i18n

使用

use Flextype\Component\I18n\I18n;

添加翻译键

I18n::add(['auth_login' => 'Login', 'auth_password' => 'Password'], [],'en_US');

返回字符串的翻译。如果不存在翻译,则返回原始字符串。没有参数被替换。

$translated_string = I18n::find('auth_login');

全局翻译/国际化函数。接受一个翻译键,并返回选定语言的翻译。如果给定的翻译键在当前字典中不可用,则返回翻译键。

// Display a translated message
echo __('auth_login', 'auth');

// With parameter replacement
echo __('auth_welcome_message', [':username' => $username], 'en_US');

设置默认区域设置

I18n::$locale = 'en_US';

许可

LICENSE