2017 © Pedro Peláez
 

translations laralang

This package let you translate strings from any language to another in laravel 5.X

image

aitor24/laralang

This package let you translate strings from any language to another in laravel 5.X

  • Thursday, December 21, 2017
  • by 24aitor
  • Repository
  • 5 Watchers
  • 38 Stars
  • 215 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 0 Open issues
  • 51 Versions
  • 4 % Grown

The README.md

Laralang

, (*1)

StyleCI Scrutinizer Latest Stable Version License , (*2)

What is Laralang?

Laralang is a laravel packages that allows you to translate your app or parts of your app from views using translations services like google or mymemory, and then store it on your DB to filter and manage easily from our admin panel., (*3)

Moreover, allows you to translate PHP files easily and then save lot of time to you., (*4)

Why use Laralang?

Personally I think the best way to translate your website is using the Laravel methods such as @lang() but sometimes it's impossible. Imagine you have a blog, and you need to translate it to different languages. With Laralang it's soo easy to do it, only place a little code like following example and laralang will translate it from your favourite translation service or well loading a stored translation on your database., (*5)

{{ Laralang::trans($post->content) }}

Getting Started

Step 1. Install it with composer

Running the command below:, (*6)

composer require aitor24/laralang

Step 2. Register service provider & aliases

Include the line below to config/app.php inside providers array :, (*7)

Aitor24\Laralang\LaralangServiceProvider::class,

Include the line below to config/app.php inside aliases array :, (*8)

'Laralang'   => Aitor24\Laralang\Facades\Laralang::class,

Step 3. Publish vendor

It will publish assets and config file., (*9)

Running the command below:, (*10)

php artisan vendor:publish

Step 4. Migrate

Running the command below:, (*11)

php artisan migrate

Step 5. Configure defalt values

STRONGLY IMPORTANT: Change the password on config (Default password: laralangAdmin ), (*12)

Apart from the password, the rest of default values can be modified also on config/laralang.php. Furthermore you can modify these in a specific translation with the functions below., (*13)

Available Translators: Google Translator, MyMemory, Apertium (Strongly not recomended), (*14)

config values for translators: 'google', 'mymemory', 'apertium', (*15)

Using laralang

Simple examples of use

Then few examples of use laralang:, (*16)

<center>
    {!! Laralang::trans('Hello world!') !!}
    <br>
    {!! Laralang::trans('Hello world!')->debug(true) !!}
    <br>
    {!! Laralang::trans('Hello world!')->to('es') !!}
    <br>
    {!! Laralang::trans('Hello world!')->to('ca') !!}
    <br>
    {!! Laralang::trans('Hello world!')->to('ca')->debug(true) !!}
    <br>
    {!! Laralang::trans('Hallo welt!')->from('de')->to('fr') !!}
    <br>
    {!! Laralang::trans('Hello world!')->to('pt') !!}
    <br>
    {!! Laralang::trans('Hello world!')->to('de') !!}
    <br>
    {!! Laralang::trans('Hello world!')->to('ml') !!}
    <br>
    {!! Laralang::trans('Hello world!')->to('zh')->translator('apertium') !!}

    <br>
    From langs:
    @foreach(Laralang::fromLanguages() as $lang)
        {{$lang}}
    @endforeach

    <br>
    To langs:
    @foreach(Laralang::toLanguages() as $lang)
        {{$lang}}
    @endforeach
</center>

NOTE: Use {{ }} statements if translations comes from users to prevent XSS atacks, (*17)

Then the result:, (*18)

Result of example, (*19)

Admin panel

Firsts steps

First you should be logged into loaralang, (*20)

Route prefix can be changed on your config file, but by default it's laralang, (*21)

  • How to acces to panel?

You should visit next url:, (*22)

http://domain/laralang/login, (*23)

or in localhost you should visit, (*24)

http://localhost/project-path/public/laralang/login, (*25)

Then you should see the laralang login page (photo below), (*26)

Laralang login page, (*27)

Now you must enter the password you set on Step 5 and then click login to manage your translations as can be seen on photos below!, (*28)

View of translations, (*29)

Editing translation #3, (*30)

Filtering translations

Laralang also lets you filter translations by from_lang and / or to_lang. Below you have an example:, (*31)

First we must access to filter view in route http://domain/laralang/translations/filter or well accessing across menu., (*32)

Menu, (*33)

Then you can select from which language provides the originals strings and then from which language are translated this string with two selectors:, (*34)

Filtering, (*35)

Then the result:, (*36)

Filtering result, (*37)

Translations via api

There exists an api to get translated text. First of all you should enable it on config, then you should configure ajax as explained in laravel official site and then call api (method=POST), (*38)

$.post('{{route("laralang::apiTranslate")}}', {'string' : 'This is my string to translate', 'to' : 'de'}, function(response) {
    var translatedText = response.translatedText;
}, 'json');

Translating PHP files

Laralang can generate PHP translations files quickly by translating from english to language you want and save a lot of time!, (*39)

After login to admin panel, you will find something like this:, (*40)

Home, (*41)

Here you simply click on translate PHP files and then you should see this view:, (*42)

Translations, (*43)

Here you can click translate and all files of resources/lang/en will be translated into languages you choose in the form input!, (*44)

Then on resources/lang/ you will find a folder for each language with it's respective files translated., (*45)

API

trans() method

This functions is used to get a translation from a string to another language specified on default values, on app_locale or in every function., (*46)

To simplify work we've implemented another package (Localizer) to set app_locale via middleware and it allows to get user browser language to set it as app_locale easily., (*47)

Functions of trans()

from(), (*48)

It sets the language of the string to translate in a specific translation., (*49)

Default: en, (*50)

to(), (*51)

It sets the language that you'll output in a specific translation., (*52)

Default: app_locale, (*53)

debug(), (*54)

Debug option let you to know the reason of an unexpected result with colorful messages in a specific translation., (*55)

Default: false, (*56)

Save(), (*57)

Save option let you to save a specific translation., (*58)

Default: false, (*59)


fromLanguages() method

Returns an array with all languages from provides strings to translate., (*60)

toLanguages() method

Returns an array with all languages that at least one string has been translated., (*61)

getLanguages() method

Returns an array with ['key' => 'value'] where key is a language and value is an acronym from all languages tested in laralang., (*62)

The Versions

21/12 2017

dev-master

9999999-dev

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

The Requires

 

21/12 2017

4.0.1

4.0.1.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

The Requires

 

24/08 2017

4.0.0

4.0.0.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

The Requires

 

24/08 2017

dev-analysis-qxw3k9

dev-analysis-qxw3k9

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

The Requires

 

24/07 2017

3.7.3

3.7.3.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

The Requires

 

11/07 2017

3.7.2

3.7.2.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

The Requires

 

11/07 2017

3.7.1

3.7.1.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

The Requires

 

09/05 2017

3.7

3.7.0.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

The Requires

 

08/02 2017

3.6

3.6.0.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

The Requires

 

08/02 2017

dev-analysis-z409l1

dev-analysis-z409l1

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

The Requires

 

07/02 2017

dev-analysis-qrGDGL

dev-analysis-qrGDGL

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

The Requires

 

31/01 2017

3.5

3.5.0.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

The Requires

 

19/12 2016

3.4.4

3.4.4.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

The Requires

 

16/12 2016

3.4.3

3.4.3.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

16/12 2016

dev-analysis-8AowZB

dev-analysis-8AowZB

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

14/12 2016

3.4.2

3.4.2.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

14/12 2016

3.4.1

3.4.1.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

11/12 2016

3.4

3.4.0.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

11/12 2016

dev-analysis-8Q0Zaw

dev-analysis-8Q0Zaw

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

10/12 2016

3.3.1

3.3.1.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

09/12 2016

3.3

3.3.0.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

09/12 2016

dev-analysis-zGG6Eo

dev-analysis-zGG6Eo

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

08/12 2016

3.2

3.2.0.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

08/12 2016

dev-analysis-zGGVMV

dev-analysis-zGGVMV

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

04/12 2016

3.1.3

3.1.3.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

04/12 2016

dev-analysis-XVjwlP

dev-analysis-XVjwlP

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

03/12 2016

3.1.2

3.1.2.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

28/11 2016

3.1.1

3.1.1.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

28/11 2016

3.1

3.1.0.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

26/11 2016

dev-analysis-qyk6MG

dev-analysis-qyk6MG

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

21/11 2016

3.0

3.0.0.0

This package let you translate strings from any language to another in laravel 5.X

  Sources   Download

MIT

19/11 2016

dev-analysis-z9nWll

dev-analysis-z9nWll

This package let you translate strings from any language to another in laravel 5.x

  Sources   Download

MIT

18/11 2016

dev-analysis-zYoROA

dev-analysis-zYoROA

This package let you translate strings from any language to another in laravel 5.x

  Sources   Download

MIT

04/11 2016

dev-analysis-863ak4

dev-analysis-863ak4

This package let you translate strings from any language to another in laravel 5.x

  Sources   Download

MIT

03/11 2016

2.3

2.3.0.0

This package let you translate strings from any language to another in laravel 5.x

  Sources   Download

MIT

03/11 2016

dev-analysis-qoWVkB

dev-analysis-qoWVkB

This package let you translate strings from any language to another in laravel 5.x

  Sources   Download

MIT

03/11 2016

dev-analysis-zeYw7r

dev-analysis-zeYw7r

This package let you translate strings from any language to another in laravel 5.x

  Sources   Download

MIT

01/11 2016

2.2.1

2.2.1.0

This package let you translate strings from any language to another in laravel 5.x

  Sources   Download

MIT

01/11 2016

2.2

2.2.0.0

This package let you translate strings from any language to another in laravel 5.x

  Sources   Download

MIT

01/11 2016

dev-analysis-zGJL1o

dev-analysis-zGJL1o

This package let you translate strings from any language to another in laravel 5.x

  Sources   Download

MIT

31/10 2016

2.1.1

2.1.1.0

Translate strings from any lenguage to another in laravel 5.

  Sources   Download

MIT

30/10 2016

dev-analysis-XZoZBa

dev-analysis-XZoZBa

Translate strings from any lenguage to another in laravel 5.

  Sources   Download

MIT

30/10 2016

2.1

2.1.0.0

Translate strings from any lenguage to another in laravel 5.

  Sources   Download

MIT

30/10 2016

2.0

2.0.0.0

This package includes a list of translations frequently used in web pages.

  Sources   Download

MIT

19/10 2016

1.2.2

1.2.2.0

This package includes a list of translations frequently used in web pages.

  Sources   Download

MIT

03/10 2016

1.2.1

1.2.1.0

This package includes a list of translations frequently used in web pages.

  Sources   Download

MIT

28/09 2016

1.2

1.2.0.0

This package includes a list of translations frequently used in web pages.

  Sources   Download

MIT

28/09 2016

1.1

1.1.0.0

This package includes a list of translations frequently used in web pages.

  Sources   Download

MIT

28/09 2016

1.0.2

1.0.2.0

This package includes a list of translations frequently used in web pages.

  Sources   Download

MIT

28/09 2016

1.0.1

1.0.1.0

This package includes a list of translations frequently used in web pages.

  Sources   Download

MIT

28/09 2016

1.0

1.0.0.0

This package includes a list of translations frequently used in web pages.

  Sources   Download

MIT