simp/translate

This is packages of simp content manager for translation

v1.0.0 2025-05-07 05:49 UTC

This package is not auto-updated.

Last update: 2025-05-07 18:36:12 UTC


README

A PHP library for easy text translation between different languages using Google Translate API with caching support.

Installation

Install the package via composer:

   composer require simp/translate

Usage

Basic usage

    require_once 'vendor/autoload.php';
    
    // Note: this will use the default translation languages, i.e., en to fr
    echo Translate::translate('Hello, How are you?');

Advance usage

   
   require_once 'vendor/autoload.php';
   
   //Note: here we are manually setting the output language ie the original text is english which will be translated to Nyanja (Chichewa)
   echo Translate::translate('Hello, How are you?', to: 'ny');
   
   // This is also possible.
   echo Translate::translate('Moni', from: 'ny', to: 'en');
   
   // Sometimes you will need to just save the translation result some where to reuse it, in that way you dont have ask google to translate everytime.
   echo Translate::translate('Hello, How are you?', to: 'ny', cacheLocation: __DIR__.'/cache');

Maintainer

Chance Nyasulu