Twig If Statement With $_SERVER variable

I am completely new to Twig and apparently have no idea what I am doing. What I want to accomplish be able to create text elements which only display according to the visitor’s browser locale. What I am attempting to do in PHP (but I guess I can’t use PHP in elements) is:

<?php $language = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); if ($language{{language}}) { ?>
<p>Hello World</p>
<?php } ?>

I made a failing attempt at twig using the following:

{% set language = app.request.server.get(“http_accept_language”)|slice(0, 2)|lower %}
{% if language{{language}} %}

Hello World


{% endif %}

My options look like this:

{
“remote”: true,
“settings”: [
{
“name”: “language”,
“label”: “Language”,
“type”: “select”,
“options”: {
“”: “Any Language”,
" and language == ‘ar’“: “Arabic”,
" and language == ‘zh’”: “Chinese”,
" and language == ‘en’“: “English”,
" and language == ‘fr’”: “French”,
" and language == ‘de’“: “German”,
" and language == ‘hi’”: “Hindi”,
" and language == ‘ko’“: “Korean”,
" and language == ‘po’”: “Polish”,
" and language == ‘es’“: “Spanish”,
" and language == ‘tl’”: “Tagalog”,
" and language == ‘yi’“: “Yiddish / Dutch”,
" and language == ‘yo’”: “Yoruba / Twi / Igbo”
},
“value”: “”
}
]
}

Can anyone offer me any insight on how to actually write this? Thank you so much.

Not sure, how this is related to MODX. Can you explain more about that?

I creating an element in ModX Fred

From reading through the web, this is what I have come up with so far and still not working:

{% set lang = app.request.getLocale()|slice(0, 2)|lower %}
{% if lang{{language}} %}

Hello World


{% endif %}