Members

(constant) CROWDIN_DIST_MIRROR :string

jsDelivr CDN URL serving Crowdin distribution files from the crowdin-dist git branch. jsDelivr unconditionally sets Access-Control-Allow-Origin: *, so cross-origin fetch() calls succeed without any browser plugin. The branch is refreshed daily by the "Sync Crowdin Distribution" workflow. Structure mirrors https://distributions.crowdin.net//… exactly.

Type:
  • string

Methods

_installCrowdinFetchInterceptor()

Monkey-patches globalThis.fetch to redirect Crowdin distribution requests to the self-hosted GitHub Pages mirror.

Must be called BEFORE proxy-translator.js is loaded so that every fetch() the script makes is already intercepted.

Idempotent – installs the interceptor at most once per page.

formatNumber(num, decimalPlaces) → {string}

Format a number to a human-readable string.

Parameters:
NameTypeDefaultDescription
numnumber

The number to format.

decimalPlacesnumber1

The number of decimal places to include in the formatted string.

Returns:

The formatted number as a string with suffix (k, M, etc.).

Type: 
string

initCrowdIn(project, platform)

Initializes Crowdin translation widget based on project and UI platform.

Parameters:
NameTypeDefaultDescription
projectstringLizardByte

Project name ('LizardByte' or 'LizardByte-docs').

platformstring | nullnull

UI platform ('sphinx', or null).

levenshteinDistance(a, b) → {number|*}

Calculate the levenshtein distance between two strings.

Parameters:
NameTypeDescription
astring

The first string to compare.

bstring

The second string to compare.

Returns:
  • The percentage of the levenshtein distance.
Type: 
number | *

loadScript(url, callback)

Load a script asynchronously, and add it to the DOM. Optionally, call a callback when the script has loaded.

Parameters:
NameTypeDescription
urlstring

The URL of the script to load.

callbackfunction

An optional callback to call when the script has loaded.

rankingSorter(firstKey, secondKey) → {function}

Sorts an array of objects by two keys in descending order.

Parameters:
NameTypeDescription
firstKeystring

The primary key to sort by.

secondKeystring

The secondary key to sort by, in case the first key is equal.

Returns:

The sorting function that returns a number.

Type: 
function

sleep(ms) → {Promise.<unknown>}

Sleep for a given amount of time.

Parameters:
NameTypeDescription
msnumber

The time to sleep in milliseconds.

Returns:

A promise that resolves after the given time.

Type: 
Promise.<unknown>