jrock
1
In php I know how to identify the current language and how to dynamically set the current language.
But is there a recommended way to detect a language change event?
I could just use if(!empty($_GET[‘language’])) but I am wondering if there is a better way?
There is already a global function named CurrentLanguageID() that you can call to get the current language id.
jrock
3
Yes I know about CurrentLanguageID() and that is what I meant by “In php I know how to identify the current language”.
At the moment I am using if(!empty($_GET[‘language’])) in the Language_Load() event to identify if the language has just been changed.
However this is quite brittle - if phpmaker ever moves away from using //blah.php?language=xyz when changing languages then this will break.
My question is whether there is a specific OnLanguageChange type of php event somewhere that is triggered upon a language change?
Doesn’t seem so but thought I would ask.
You may still use “Language_Load” server event in order to define the phrases based on the active language id, for example:
if (CurrentLanguageID() == “en”) {
$this->setPhrase(“AddBtn”, “Add New Record”);
} elseif (CurrentLanguageID() == “it”) {
$this->setPhrase(“AddBtn”, “Aggiungi nuovo record”);
}