PageSourceSearch

https://ubuntu.com/static/js/src/infer-preferred-language.js?v=b69e09e

js ubuntu.com collected 2026-09-24 06:03:17 UTC 678 bytes, 27 lines download raw bytes

1function getPrimaryParentLanguage() {
2  /**
3   * Get the primary parent language
4   *
5   * Get the user's default language, and if it's a sub-language,
6   * infer the parent language - e.g. for "en-GB", infer "en"
7   */
8  var language =
9    navigator.language ||
10    navigator.userLanguage ||
11    navigator.browserLanguage ||
12    navigator.systemLanguage;
13
14  if (language.indexOf("-") !== -1) {
15    if (language !== "zh-TW") {
16      language = language.split("-")[0];
17    }
18  }
19
20  return language;
21}
22
23const preferredLanguageInput = document.querySelector("#preferredLanguage");
24
25if (preferredLanguageInput) {
26  preferredLanguageInput.value = getPrimaryParentLanguage() || "";
27}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.