[1.7.x] Fixed #24063 -- Locale code validation too strict

The locale code can contain variant after @, so let's allow the
validation of it to pass.

Backport of 7c4393689f2e54993d57958d02a4757d84133d50 from master.