PHP code example of manujoz / translation

1. Go to this page and download the library: Download manujoz/translation library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

manujoz / translation example snippets




return [
	"hello" => "Hi!",
	"bye" => "Good bye",
	"login.messages.ok" => "You are logged",
	"signup.messages.welcome" => "Welcome to my site {name}"
]




return [
	"hello" => "¡Hola!",
	"bye" => "Adios",
	"login.messages.ok" => "Estás dentro",
	"signup.messages.welcome" => "Bienvenido a mi sitio {name} ({email})"
]




use Manujoz\Translation\Translation;

 "en-EN";
echo $TRANS->of( "hello" ) . "<br>";
echo $TRANS->of( "signup.messages.welcome", [ "name" => "Manu Overa", "email" => "[email protected]" ] ) . "<br>";
echo $TRANS->of( "bye" ) . "<br>";

$TRANS->lang = "es-ES";
echo $TRANS->of( "hello" ) . "<br>";
echo $TRANS->of( "signup.messages.welcome", [ "name" => "Manu Overa", "email" => "[email protected]" ] ) . "<br>";
echo $TRANS->of( "bye" ) . "<br>";




use Manujoz\Translation\Translation;

on1" );



$TRANS->of( $key, $params = array() );




$TRANS->set_enclosing_chars( [ "[[", "]]" ] );




return [
	"hello" => "Hi!",
	"bye" => "Good bye",
	"login.messages.ok" => "You are logged",
	"signup.messages.welcome" => "Welcome to my site {not will be replaced} [[willBeReplaced]]"
]


|ROOT
	|_	locales
	|		   |_ en-US.php
	|		   |_ es-ES.php
	|		   |_ fr-FR.php
	|_	index.php

|ROOT
	|_	translates
	|		   |_ section1
	|		   |          |_ en-US.php
	|		   |          |_ es-ES.php
	|		   |          |_ fr-FR.php
	|		   |_ section2
	|		   |          |_ en-US.php
	|		   |          |_ es-ES.php
	|		   |          |_ fr-FR.php
	|_	index.php