it-bens/simple-words-translator

Translator for simple and widely used words in different languages

v0.2.1 2024-03-23 19:05 UTC

This package is auto-updated.

Last update: 2024-04-23 19:24:19 UTC


README

Tests codecov

A simple problem with a simple solution.

This is a simple package that provides translations for defined words like "yes" and "no" (in english). The desired language can be passed by name or or ISO code (2 letter).

Installation

composer require it-bens/simple-words-translator

Usage

use ITB\SimpleWordsTranslator\TranslatorByName;

$translator = new TranslatorByName();
$translation = $translator->yes('Deutsch'); // 'Ja'
$translation = $translator->no('deutsch'); // 'Nein'
use ITB\SimpleWordsTranslator\TranslatorByIsoCode;

$translator = new TranslatorByIsoCode();
$translation = $translator->yes('de'); // 'Ja'
$translation = $translator->no('de'); // 'Nein'

The package provides interfaces for the two translators. All translations implement the ITB\SimpleWordsTranslator\Translation interface.

Supported Languages

  • German
  • English
  • Spanish
  • French
  • Italian
  • Dutch