Jump to content
Remitur

How to recover language variable value in php?

Recommended Posts

Hello.

Having defined some language variable, i.e.

$_LANG['mylangvariable'] = "This is my language variable";

how can I recover the value of $_LANG['mylanguagevariable']  to use it in a php hook?!

Share this post


Link to post
Share on other sites
Posted (edited)
3 minutes ago, Remitur said:

how can I recover the value of $_LANG['mylanguagevariable']  to use it in a php hook?!

the usual way would be Lang::trans('mylanguagevariable')

Edited by brian!

Share this post


Link to post
Share on other sites
6 minutes ago, brian! said:

the usual way would be Lang::trans('mylanguagevariable')

Yes, but does exist any way to recover directly the variable?
My previous example was not properly chosen, let's say I need to recover a language array, as:
$_LANG['mylanguagevariable'] ['first']="aaaa";
$_LANG['mylanguagevariable'] ['second']="bbbbb";

It it somehow possible to recover the whole array $LANG['mylanguagevariable']     ?
 

(a very dirty way, not tested by I guess it should works, would be a require, i,.e.    require('lang/override/' . $language . '.php');    .... but it's a very dirty way to do it, and don't know if it may bring with some kind of issue with WHMCS core)

 

Share this post


Link to post
Share on other sites
25 minutes ago, Remitur said:

Yes, but does exist any way to recover directly the variable?

declare the variable globally - then you can reference any element of it in the hook.

so in the above example, i'm using a hook to effectively override a language string - in your case, declare $_LANG globally, then you can access it as you can with any other array.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated