Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
quarto-dev
GitHub Repository: quarto-dev/quarto-cli
Path: blob/main/src/config/localization.ts
6449 views
1
/*
2
* localization.ts
3
*
4
* Copyright (C) 2020-2022 Posit Software, PBC
5
*
6
*/
7
8
import { Format } from "./types.ts";
9
10
export function localizedString(
11
format: Format,
12
key: string,
13
options?: string[],
14
) {
15
if (options) {
16
let formattedStr = format.language[key] as string;
17
for (let i = 0; i < options.length; i++) {
18
const option = options[i];
19
formattedStr = formattedStr.replace(`{${i}}`, option);
20
}
21
return formattedStr;
22
} else {
23
return format.language[key] as string;
24
}
25
}
26
27