We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8d53b5a commit 002fca8Copy full SHA for 002fca8
1 file changed
cloud-function/src/internal/locale-utils/index.js
@@ -102,9 +102,13 @@ export function getLocale(
102
103
// Each header in request.headers is always a list of objects.
104
const value = getAcceptLanguage(request);
105
+ // Try a strict match first so that e.g. `zh-TW` resolves to `zh-TW`
106
+ // rather than the first `zh-*` entry in the supported list. Fall back to
107
+ // a loose match so that e.g. `en-GB` still resolves to `en-US`.
108
const locale =
109
value &&
- acceptLanguageParser.pick(validLocalesList, value, { loose: true });
110
+ (acceptLanguageParser.pick(validLocalesList, value) ||
111
+ acceptLanguageParser.pick(validLocalesList, value, { loose: true }));
112
return locale || fallback;
113
}
114
0 commit comments