How to make the script more multi-functional PHP?

Good day have the following script
<?php $urlCurrent = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; #get URL ?> // 
 <?php $langed= ICL_LANGUAGE_CODE; #function of the plugin to output the current language ?>
 <?php $newUrlEn = str_replace('/EN/', '/en/', $urlCurrent); ?>
 <?php $newUrlUa = str_replace('/EN/', '/ua/', $urlCurrent); ?>

The situation is this, I have a website in 3 languages. Ru/EN/UA.
URL they have such
Ie done so that just the language has changed

The only problem is that str_replace can be used not always
If for example the user is on the Ukrainian version of the str_replace will not find the /EN/ in the URL
And so the question arises, how to do that though in any language I could get to change all 3 URLs
For example, I find on the about us page
To change still
April 7th 20 at 15:36
1 answer
April 7th 20 at 15:38
The concatenation of domain, additional languages and addresses section of the site.

Find more questions by tags PHP