mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-24 17:35:10 +03:00
64896d70b0
This reflects changes in Google's policy on JavaScript license headers, which should be smaller to avoid increasing the size of the binary unnecessarily. This also updates the company name from "Google, Inc" to "Google LLC". Change-Id: I3f8b9ed3700b6351f43173d50c94d35c333e82b4
40 lines
899 B
JavaScript
40 lines
899 B
JavaScript
/** @license
|
|
* Copyright 2016 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
goog.provide('shaka.polyfill.Languages');
|
|
|
|
goog.require('shaka.polyfill');
|
|
|
|
|
|
/**
|
|
* @summary A polyfill to provide navigator.languages on all browsers.
|
|
* This is necessary for IE and possibly others we have yet to discover.
|
|
*/
|
|
shaka.polyfill.Languages = class {
|
|
/**
|
|
* Install the polyfill if needed.
|
|
*/
|
|
static install() {
|
|
if (navigator.languages) {
|
|
// No need.
|
|
return;
|
|
}
|
|
|
|
Object.defineProperty(navigator, 'languages', {
|
|
get: () => {
|
|
// If the browser provides a single language (all that we've seen), then
|
|
// make an array out of that. Otherwise, return English.
|
|
if (navigator.language) {
|
|
return [navigator.language];
|
|
}
|
|
return ['en'];
|
|
},
|
|
});
|
|
}
|
|
};
|
|
|
|
|
|
shaka.polyfill.register(shaka.polyfill.Languages.install);
|