MCPcopy Index your code
hub / github.com/coder/code-server / loadCustomStrings

Function loadCustomStrings

src/node/i18n/index.ts:27–48  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

25}
26
27export async function loadCustomStrings(filePath: string): Promise<void> {
28 try {
29 // Read custom strings from file path only
30 const fileContent = await fs.readFile(filePath, "utf8")
31 const customStringsData = JSON.parse(fileContent)
32
33 // User-provided strings override all languages.
34 Object.keys(defaultResources).forEach((locale) => {
35 i18next.addResourceBundle(locale, "translation", customStringsData)
36 })
37 } catch (error) {
38 if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
39 throw new Error(`Custom strings file not found: ${filePath}\nPlease ensure the file exists and is readable.`)
40 } else if (error instanceof SyntaxError) {
41 throw new Error(`Invalid JSON in custom strings file: ${filePath}\n${error.message}`)
42 } else {
43 throw new Error(
44 `Failed to load custom strings from ${filePath}: ${error instanceof Error ? error.message : String(error)}`,
45 )
46 }
47 }
48}
49
50init({
51 lng: "en",

Callers 2

i18n.test.tsFile · 0.90
runCodeServerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected