What does $L refer to?

Post Reply
User avatar
cobber
Master Bludit
Posts: 78
Joined: Sun Feb 28, 2016 10:15 am
Location: Scotland
Has thanked: 21 times
Been thanked: 5 times

Morning

I've been looking into theme development and have downloaded several to get a better understanding.

In one theme I came across (Blekathlon) uses the following:

Code: Select all

$L->get
For the life of me I cannot see where this is referencing.
What is $L ?

I assume it's related to an object, I just can't locate where it is initialised.
I'm just trying to get a better understanding of Bludit.

Many thanks
User avatar
novafacile
Master Bludit
Posts: 107
Joined: Sat Oct 06, 2018 4:47 pm
Has thanked: 35 times
Been thanked: 10 times
Contact:

This is the global object for translations:

https://docs.bludit.com/en/languages/translate-themes

https://docs.bludit.com/en/languages/translate-plugins

Bludit has also some basic translations in /bl-languages

The easiest way to understand is to look into a translation file and a plugin.
User avatar
cobber
Master Bludit
Posts: 78
Joined: Sun Feb 28, 2016 10:15 am
Location: Scotland
Has thanked: 21 times
Been thanked: 5 times

Many thanks

Will take a look
User avatar
cobber
Master Bludit
Posts: 78
Joined: Sun Feb 28, 2016 10:15 am
Location: Scotland
Has thanked: 21 times
Been thanked: 5 times

Looked in the translations section as suggested but don't see any reference to the following:

$L->get()

Maybe I'm missing something. The section just refers to .json files being used.

Will keep investigating

Many thanks
User avatar
cobber
Master Bludit
Posts: 78
Joined: Sun Feb 28, 2016 10:15 am
Location: Scotland
Has thanked: 21 times
Been thanked: 5 times

After a detailed search, I found the reference

Code: Select all

// --- Objects with dependency ---
$language = new Language( $site->language() );

// --- Objects shortcuts ---
$L = $language;
So I assume (hopefully correctly) that when using the function

Code: Select all

$L->get('Continue reading')
the return value is a translation of the language currently being used
ie: 'Continue reading' in English or Spanish or whatever is set in the admin
User avatar
novafacile
Master Bludit
Posts: 107
Joined: Sat Oct 06, 2018 4:47 pm
Has thanked: 35 times
Been thanked: 10 times
Contact:

That's correct.

If you use the language object in function/method you need to enable the access via "global".

Code: Select all

global $L;
Post Reply