PHP code example of pragmarx / glottos

1. Go to this page and download the library: Download pragmarx/glottos 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/ */

    

pragmarx / glottos example snippets



// Use the Facade to set a locale

Glottos::setLocale('pt_BR');

// And just use it

Glottos::translate('Laravel is a PHP Framework');

// There's a helper

g('Laravel is a PHP Framework');

// Choose a particular locale

Glottos::translate('Laravel is a PHP Framework', 'pt_BR')

// or 

Glottos::translate('Laravel is a PHP Framework', 'pt-br')

// Glottos let you choose between keys and natural language:

Glottos::translate('key::home.describe.laravel') 
Glottos::translate('natural::Laravel is a PHP Framework') 

// or you can just define your default as natural and use:

Glottos::translate('Laravel is a PHP Framework') 

// It will break your paragraphs in sentences

Glottos::translate('Laravel is a PHP Framework. Laravel was written by Taylor Otwell.')

// To not repeat itself, it will store those two sentences in your database:

'Laravel is a PHP Framework'
'Laravel was written by Taylor Otwell'

// Removing punctuation and special chars.

// With a simple blade trick 

Blade::extend(function ($view) {

	return preg_replace(
		                 '/{{\'((.|\s)*?)\'}}/', 
	                     ' echo Glottos::translate("$1"); 

php artisan migrate --package=pragmarx/glottos