Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | 53x 3x 3x | import Sentry from "platform/sentry";
/** A language tracked by weblate (either the base English language or a translated language). */
export interface WeblateLanguage {
/** The Weblate language code, based on ISO but using underscores, e.g. "pt_BR". */
code: string;
/** The English name of the language as reported by Weblate. */
name: string;
/** The progress percentage of the translation. */
translated_percent: number;
}
/** Converts a Weblate language code (e.g. "pt_BR") to its ISO-style locale code (e.g. "pt-BR"). */
export function weblateToISOLocale(code: string): string {
return code.replace("_", "-");
}
/** Queries Weblate for known languages and their translation progress. */
export async function fetchWeblateLanguages(): Promise<WeblateLanguage[]> {
const response = await fetch("https://cdn.couchers.org/api/projects/couchers/languages/", {
headers: {
Accept: "application/json",
},
});
if (!response.ok) {
const error = new Error(`Weblate API error: ${response.status} ${response.statusText}`);
Sentry.captureException(error);
throw error;
}
const languages: WeblateLanguage[] = await response.json();
return languages || [];
}
|