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/
- string
- Source
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.
- Source
formatNumber(num, decimalPlaces) → {string}
Format a number to a human-readable string.
| Name | Type | Default | Description |
|---|---|---|---|
num | number | The number to format. | |
decimalPlaces | number | 1 | The number of decimal places to include in the formatted string. |
- Source
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.
| Name | Type | Default | Description |
|---|---|---|---|
project | string | LizardByte | Project name ('LizardByte' or 'LizardByte-docs'). |
platform | string | | null | UI platform ('sphinx', or null). |
- Source
levenshteinDistance(a, b) → {number|*}
Calculate the levenshtein distance between two strings.
| Name | Type | Description |
|---|---|---|
a | string | The first string to compare. |
b | string | The second string to compare. |
- Source
- 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.
| Name | Type | Description |
|---|---|---|
url | string | The URL of the script to load. |
callback | function | An optional callback to call when the script has loaded. |
- Source
rankingSorter(firstKey, secondKey) → {function}
Sorts an array of objects by two keys in descending order.
| Name | Type | Description |
|---|---|---|
firstKey | string | The primary key to sort by. |
secondKey | string | The secondary key to sort by, in case the first key is equal. |
- Source
The sorting function that returns a number.
- Type:
- function
sleep(ms) → {Promise.<unknown>}
Sleep for a given amount of time.
| Name | Type | Description |
|---|---|---|
ms | number | The time to sleep in milliseconds. |
A promise that resolves after the given time.
- Type:
- Promise.<unknown>