Use Language instead of file extension to choose live dev document type

Fixes #3307

Also, update ``Document`` language before reading file content.