kiumars-babolhavaeji/simple-php-translator
最新稳定版本:v1.0.1
Composer 安装命令:
composer require kiumars-babolhavaeji/simple-php-translator
包简介
a package for translate names from a web resource
README 文档
README
SimpleTranslator is a lightweight and extensible PHP library for managing translations in multiple languages. It supports various file formats, dynamic configurations, caching, and features like pluralization and gender-specific translations.
Features
- Dynamic Configurations: Customize settings via environment variables or config files.
- Multi-Format Support: JSON, YAML, and XML translation files are supported.
- Fallback Language: Automatically falls back to a default language if a translation file is missing.
- Error Handling: Gracefully handles missing or unreadable files and keys.
- Caching: Reduces repeated lookups by caching translations.
- Pluralization and Gender-Specific Translations: Adapts based on count and gender.
installation
The package is available on github and packagist, so for install and use this package you just need to install it by composer :
composer require kiumars-babolhavaeji/simple-php-translator
Usage
- Configure the Library Set environment variables for dynamic configurations:
export TRANSLATOR_LANGUAGE=en
export TRANSLATOR_TYPE=.json
export TRANSLATOR_ROOT=/path/to/translations
- Translation Example
use SimpleTranslator\Lang;
echo Lang::translate('hello'); // Output: Translation of 'hello'
echo Lang::translate('apple', ['count' => 2]); // Output: Apples (based on pluralization)
echo Lang::translate('actor', ['gender' => 'female']); // Output: Actress
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-24