This is a an improved way of language detection function
Why this?
This ensures addition of more supported languages does not lead to modification of detectLanguage and getSupportedLanguages functions and new introduction of if else statements
How are you doing this?
All languages and their extensions have been put into a map (hash table) with the language as keys and the list of extensions as values.
detectLanguage loops through the extensions and return the first language it gets a match for.
What is this?
This is a an improved way of language detection function
Why this?
This ensures addition of more supported languages does not lead to modification of
detectLanguage
andgetSupportedLanguages
functions and new introduction of if else statementsHow are you doing this?
detectLanguage
loops through the extensions and return the first language it gets a match for.