You don't need a custom module for this.
Drupal can have seperate language detection for interface (menu item/interface elements) and content. There was a bug that was fixed recently so make sure you are on the latest 8.6.x version.
Assuming you have enabled all 4 core language modules and you have enabled at least 1 extra language than configure the language detection methods to accomplish what you want as I its outlined below.
Configuration > Regional and language > Languages > Detection and selection and
- enable Account administration pages. This will allow each user to choose their preferred interface language (there will be a new option when they edit their profile page)
- enable content language detection. This will make available the
language switcher (content)) block.
- enable 1 detection method. In my case I choose url (i.e. /en /fr) but you can choose any other or more methods if you like.
ΝΟΤΕ: The detection methods take precedence as they appear from top to bottom provided they are also enabled.
Structure > Block layout and enable
language switcher (content) (not
language switcher (interface text)
Now lets say a user has chosen English as their
interface language they can press on the
language switcher (content) and their interface (menu, admin menu etc) will always stay English.