How to get custom language phrases?

I make the following additions to the “english.en-US.xml” and “turkish.tr-TR.xml” files:

<phrase id="SearchCriteria" value="Search Criteria" />
<phrase id="SearchCriteria" value="Arama Kriterleri" />

Then, when I write the following code in the “Server Events → Table Specific → List Page → Page_DataRendering” section, I get an error.

$message .= "<p class='font-weight-bold mb-2'>" . $Language->phrase("SearchCriteria") . ":</p>";

The error is as follows:
Call to a member function phrase() on null

I added this code and I think it worked:

global $Language;
if (!isset($Language)) {
$Language = new Language();
}

you don’t need all that

myfunction() {
$Language = Language();

echo $Language->phrase("SearchCriteria") ."<br>";
}

You may simply change that code to:

Language()->phrase("SearchCriteria")