Exclude /ru/ in links
You can change the way the language is added to the url. For the Russian language (your default language), you can remove it completely from the url by setting the path prefix to empty value.

This can be done under admin/config/regional/language/edit/ru, set empty value on Path prefix language code.

Theoretically you don't need to have custom code the generate URL (with language checks), just let Drupal handle the url generation.