Bug 897069: Set the locale code for the document as soon as possible. r=stas