A convenience package for php multilingual web applications

Last update: Sep 27, 2021

PHP Translation

It is a php package that enables multi-language capability very easily. Also, the package accepts formats as array, json and Database.

Install

    composer require ahmetbarut/translation

Lifecycle

diagram

Configuration

The directory structure of the language files should be as follows and it should return an array. The location of the directory is not important, but the content is!


  • lang
    • en
      • menu.php / menu.json
    • tr
      • menu.php / menu.json
    • de
      • menu.php / menu.json

Content of PHP File

    return [
    'home' => 'Home',
];

Content of Json File

    {
        "home": "Home",
        "deneme": "TEST"
    }

Content Of Database Table

You can change the table name as you wish. If the table name is different, you must give the table name to the $table parameter in the constructor of the Translation class.

CREATE TABLE translation (
    id serial PRIMARY KEY,
    key varchar (255),
    value VARCHAR (255),
    language VARCHAR(255)
    )

Use Of

Array Or Json

setLocale('en'); trans('menu.home') ">
use ahmetbarut\Translation\Translation;

require "./vendor/autoload.php";

$translation = new Translation(__DIR__ . '/lang', 'array');
$translation->setLocale('en');

trans('menu.home')

The trans function accepts a string and the first word before the period represents the file, and the word after the period is the key to the requested value.

The setLocale method also belongs to the Translation class.

Database

getMessage()); } $translation = new Translation( format: 'db', connect: $connect, table: 'translation_words'); $translation->setLocale('en'); trans('home') ">
use ahmetbarut\Translation\Translation;

require "./vendor/autoload.php";

try {
    $connect = new PDO('pgsql:host=localhost;dbname=translation;', 'ahmetbarut', "");
}catch (PDOException $th){
    die($th->getMessage());
}

$translation = new Translation( format: 'db', connect: $connect, table: 'translation_words');
$translation->setLocale('en');

trans('home')

The trans function does not expect . in this case.

GitHub

https://github.com/ahmetbarut/php-translation
You might also like...

A multilingual, extensible, community oriented CMS developed in PHP

A multilingual, extensible, community oriented CMS developed in PHP

ImpressCMS is a community developed Content Management System. With this tool maintaining the content of a website becomes as easy as writing a word d

May 20, 2022

Multilingual PHP CMS built with Laravel and bootstrap

Multilingual PHP CMS built with Laravel  and bootstrap

Lavalite This is an open source of Content Management System developed with Laravel framework. Documentation Visit Documentation section in the websit

May 23, 2022

Easy multilingual urls and redirection support for the Laravel framework

Linguist - Multilingual urls and redirects for Laravel This package provides an easy multilingual urls and redirection support for the Laravel framewo

Feb 13, 2022

Multilingual CMS built with Laravel.

Multilingual CMS built with Laravel.

TypiCMS TypiCMS is a modular multilingual content management system built with Laravel. Out of the box you can manage pages, events, news, places, men

May 18, 2022

Multilingual CMS built with Laravel.

Multilingual CMS built with Laravel.

TypiCMS TypiCMS is a modular multilingual content management system built with Laravel. Out of the box you can manage pages, events, news, places, men

Jun 25, 2021

Polymorphic and Multilingual CMS powered by Laravel

Nuclear CMS Polymorphic and multilingual content management system. Nuclear is a polymorphic and multilingual content management system powered by Lar

Feb 24, 2022

Get estimated read time of an article. Similar to medium.com's "x min read". Multilingual including right-to-left written languages. Supports JSON, Array and String output.

Read Time Calculates the read time of an article. Output string e.g: x min read or 5 minutes read. Features Multilingual translations support. Static

Sep 7, 2021

A modular multilingual CMS built with Laravel 5.

AsgardCMS Platform View the documentation at AsgardCMS.com/docs. Join the conversation on Slack License The AsgardCMS is open-sourced software license

May 7, 2022

Trait for multilingual resource file support

⚡ Usage This library supports MultilingualResourceTrait which can be used in PluginBase. Multilingual support of resource files is possible using this

Oct 23, 2021

Trait for multilingual resource file support

⚡ Usage This library supports MultilingualResourceTrait which can be used in PluginBase. Multilingual support of resource files is possible using this

Oct 23, 2021

Discuz!ML is a multilingual version of Discuz!X, social network engine from Tencent Cloud

Discuz! ML (MultiLingual Discuz) Introduction Discuz!ML is a multilingual version of Discuz!X, social network engine from Tencent Cloud Related Sites

May 24, 2022

Searches for multilingual phrases in Laravel project and automatically generates language files for you.

Searches for multilingual phrases in Laravel project and automatically generates language files for you.

Laravel Lang Generator Searches for multilingual phrases in a Laravel project and automatically generates language files for you. You can search for n

Mar 30, 2022

Roundcube Webmail is a browser-based multilingual IMAP client with an application-like user interface.

Roundcube Webmail roundcube.net ATTENTION This is just a snapshot from the GIT repository and is NOT A STABLE version of Roundcube. It's not recommend

May 27, 2022

Laravel Multilingual Models

Laravel Multilingual Models Make Eloquent model attributes translatable without separate database tables for translation values. Simply access $countr

Feb 8, 2022

FlyCubePHP is an MVC Web Framework developed in PHP and repeating the ideology and principles of building WEB applications, embedded in Ruby on Rails.

FlyCubePHP FlyCubePHP is an MVC Web Framework developed in PHP and repeating the ideology and principles of building WEB applications, embedded in Rub

Dec 21, 2021

Damn Vulnerable Web Services is an insecure web application with multiple vulnerable web service components that can be used to learn real world web service vulnerabilities.

Damn Vulnerable Web Services is an insecure web application with multiple vulnerable web service components that can be used to learn real world web service vulnerabilities.

Damn Vulnerable Web Services is an insecure web application with multiple vulnerable web service components that can be used to learn real world web service vulnerabilities.

May 9, 2022

Traits used primarily in the v6 package but also available as a helper package for applications

Phalcon Traits This package contains traits with methods that are used for Phalcon v6 onward. It can also be useful to others that want short snippets

Nov 19, 2021

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.

Slim Framework Slim is a PHP micro-framework that helps you quickly write simple yet powerful web applications and APIs. Installation It's recommended

May 21, 2022

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast! Condensed in a single ~65KB file

May 22, 2022
Easy multilingual urls and redirection support for the Laravel framework

Linguist - Multilingual urls and redirects for Laravel This package provides an easy multilingual urls and redirection support for the Laravel framewo

Feb 13, 2022
Trait for multilingual resource file support

⚡ Usage This library supports MultilingualResourceTrait which can be used in PluginBase. Multilingual support of resource files is possible using this

Oct 23, 2021
Package to manage Laravel translations locally
Package to manage Laravel translations locally

Translation Manager For Laravel Easy to use package that helps you with the translation of your Laravel application locally. Features ✅ Check all loca

Jan 8, 2022
PHP library to collect and manipulate gettext (.po, .mo, .php, .json, etc)

Gettext Note: this is the documentation of the new 5.x version. Go to 4.x branch if you're looking for the old 4.x version Created by Oscar Otero http

May 15, 2022
Patchwork UTF-8 for PHP: Extensive, portable and performant handling of UTF-8 and grapheme clusters for PHP

Patchwork UTF-8 for PHP Patchwork UTF-8 gives PHP developpers extensive, portable and performant handling of UTF-8 and grapheme clusters. It provides

Feb 20, 2022
A morphological solution for Russian and English language written completely in PHP.
A morphological solution for Russian and English language written completely in PHP.

Morphos A morphological solution for Russian and English language written completely in PHP. Tests & Quality: Features [✓] Inflection of Personal name

May 20, 2022
Geographer is a PHP library that knows how any country, state or city is called in any language
Geographer is a PHP library that knows how any country, state or city is called in any language

Geographer Geographer is a PHP library that knows how any country, state or city is called in any language. Documentation on the official website Incl

May 17, 2022
[Deprecated] A Laravel package for multilingual models
[Deprecated] A Laravel package for multilingual models

This package has been deprecated. But worry not. You can use Astrotomic/laravel-translatable. Laravel-Translatable If you want to store translations o

Apr 20, 2022
A Laravel package for multilingual models
A Laravel package for multilingual models

Introduction If you want to store translations of your models into the database, this package is for you. This is a Laravel package for translatable m

May 21, 2022
Multilingual PHP CMS built with Laravel and bootstrap
Multilingual PHP CMS built with Laravel  and bootstrap

Lavalite This is an open source of Content Management System developed with Laravel framework. Documentation Visit Documentation section in the websit

May 28, 2022