g.http() does not default to English for unsupported languages
codechennerator opened this issue · 2 comments
Issue: g.http() does not default to English for unsupported languages
Bringing up another issue that was found with the g.http() function.
var g = require('strong-globalize')();
let req = {
headers: {
'accept-language': 'id' // Language not supported
}
}
g.http(req).log('Hello'); // prints out ' ah-hoy' (This language is in Czech. It does NOT default to English
This occurs only in the http() function due to the accept-language module here https://github.com/strongloop/strong-globalize/blob/master/packages/runtime/src/helper.ts#L883-L884. This is because the accept-language module uses the first language in the appLanguages array as the default language. In order for g.http() to choose the default language correctly, a simple solution can be implemented where the default language is added to the front of the language list.
An argument can be made that the accept-language
module should be responsible for allowing a defaultLanguage to be selected. However, it seems that the accept-language module is not being updated anymore. (I opened an issue with them a few months back tinganho/node-accept-language#36)
Made a PR here: #165