API for reading extra information from the HTTP header Accept-Language based on the Language subtag registry file.
Details for the Accept-Language HTTP header can be found at the Tags for Identifying Languages, which refers to the Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content.
const al_api = require('@dptole/al-api')
al_api.getLanguageDescriptionBySubtag('en') // ['English']
al_api.getRegionDescriptionBySubtag('US') // ['United States']
al_api.getAcceptLanguageInfo('pt,pt-BR;q=0.9,es-VE;q=0.8')
/*
[{
'language': {
'subtag': 'pt',
'info': ['Portuguese']
}
}, {
'language': {
'subtag': 'pt',
'info': ['Portuguese']
},
'region': {
'subtag': 'BR',
'info': ['Brazil']
}
}, {
'language': {
'subtag': 'es',
'info': ['Castilian']
},
'region': {
'subtag': 'VE',
'info': ['Venezuela']
}
}]
*/