Yes, the code above requires a special language field.
Otherwise you have to use a custom filter that checks if the page is available in the respective language, like in the switch example: Language switcher example creating invalid URLs for missing translations