azettl/php-nano-translation

php-nano-translation 类可以为您从请求的 JSON 文件中提供正确的翻译。

0.0.1 2017-08-02 14:49 UTC

This package is auto-updated.

Last update: 2024-09-05 22:12:04 UTC


README

Codacy Badge Codacy Badge

php-nano-translation 类可以为您从请求的 JSON 文件中提供正确的翻译。

安装

composer require azettl/php-nano-translation

使用

require __DIR__ . '/vendor/autoload.php';

$oTranslation = new com\azettl\nano\translation();
$oTranslation->setBasePath('vendor/azettl/php-nano-translation/tests/translations/');
$oTranslation->setFileNamePattern('test.%s.json');

echo $oTranslation->translate('MY_KEY_WITH_VARS', 'en', ['variable' => 'test']);

翻译键值:"My {variable} Value" 返回:"My test Value"