Part 1
Accept-Language: en-US, fr-CA, fr-FR
means that the reader would accept:
1. English as spoken in the United States (most preferred)
2. French as spoken in Canada
3. French as spoken in France (least preferred)
We're writing a server that needs to return content in an acceptable language
for the requester, and we want to make use of this header. Our server doesn't
support every possible language that might be requested (yet!), but there is a
set of languages that we do support. Write a function that receives two arguments:
an Accept-Language header value as a string and a set of supported languages,
In addition to writing this function, you should use tests to demonstrate that it's
correct, either via an existing testing system or one you create.
Examples:
parseacceptlanguage(
["fr-FR", "en-US"] # the server's supported languages, a set of strings
)
returns: ["en-US", "fr-FR"]
parseacceptlanguage("fr-CA, fr-FR", ["en-US", "fr-FR"])
returns: ["fr-FR"]
parseacceptlanguage("en-US", ["en-US", "fr-CA"])
returns: ["en-US"]***