Case-insensitive lang search for i8n, along with support for match just lang, without region, ie. 'en' == 'en-US'

This commit is contained in:
simojenki
2021-08-16 10:50:56 +10:00
parent c67f74bf08
commit 2cfd52415c
5 changed files with 114 additions and 68 deletions

View File

@@ -536,9 +536,10 @@ function bindSmapiSoapServiceToExpress(
.then(splitId(id))
.then(({ musicLibrary, accessToken, type, typeId }) => {
const paging = { _index: index, _count: count };
const lang = i8n((headers["accept-language"] || "en-US") as LANG);
const acceptLanguage = headers["accept-language"];
const lang = i8n((acceptLanguage || "en-US") as LANG);
logger.debug(
`Fetching metadata type=${type}, typeId=${typeId}, lang=${lang}`
`Fetching metadata type=${type}, typeId=${typeId}, acceptLanguage=${acceptLanguage}`
);
const albums = (q: AlbumQuery): Promise<GetMetadataResponse> =>