kiumars-babolhavaeji/simple-php-translator

a package for translate names from a web resource

Installs: 5

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/kiumars-babolhavaeji/simple-php-translator

v1.0.1 2022-07-23 09:12 UTC

This package is auto-updated.

Last update: 2025-11-05 18:11:17 UTC


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

  1. Configure the Library Set environment variables for dynamic configurations:
export TRANSLATOR_LANGUAGE=en
export TRANSLATOR_TYPE=.json
export TRANSLATOR_ROOT=/path/to/translations
  1. 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