But "gb" is not a language but a country. Should'nt we get a compilation error here?
The compiler doesn't have a way to know what value you are passing/assigning. It only knows the type of the object/value you pass.
In this particular case, the compiler knows you are passing a String type value, but it doesn't have a way to know what it actually contains.
The closest possible error handling would have been throwing an exception (something like IllegalArgumentException would have been a good choice) when you pass an unrecognized value. However, for some reason the people who designed it decided to be gentle on invalid names.