pleinx/php-multilang-any

A simple resolver for language snippets.

2.0.0 2021-11-30 23:36 UTC

This package is auto-updated.

Last update: 2024-10-29 05:10:34 UTC


README

Latest Stable Version Total Downloads compatible License

fyi: Currently not complete documented :-) Working on it...

Description

Handles easy your translations for your multi language PHP Project.

Basic Features

Translator Features

  • Write your own Translate Function like __('foo', ['bar'])
  • Supports HTML-Markup in Translation

Installation via Composer

composer require pleinx/php-multilang-any
Don't have Composer?

Just download it here: https://getcomposer.org/

Basic Usage

Translate::__e('Foo', ['Bar']);
// Output "Foo is nicer than Bar"

By default the TranslatorAPI load the Translations in ./languageFiles/.

Notice: You find all these default parameters here.

Customize

$settings = (new TranslatorSettings())
    ->setIsProduction(false)
    ->setLanguage('de')
    ->setFallbackLanguage('en')
    ->setLanguageFilesPath(__DIR__ . '/lang');

new TranslatorAPI($settings);

Notice: Or just change the Default Settings, see here.

Language Resource Example (JSON)

// package_serach.json
{
    "results.success.text": "Your search Results for {{searchTerm}}.",
    "results.failed.text": "Nothing found for {{searchTerm}}",
    "results.success.itemsInCategories": "Found {{itemsCount}} in {{categories}}"
}

Requirements

  • PHP 7.4 and above (tested with php8)