Add general locale selection

based on the locale info in the grammar and the name of the concrete language.

See also the discussion at commit ce3bffabe1ec83