mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-30 01:36:24 +01:00 
			
		
		
		
	feat(test): ensure frontend translations are valid JSON
This commit is contained in:
		
							
								
								
									
										19
									
								
								src/services/i18n.spec.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/services/i18n.spec.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | |||||||
|  | import { describe, expect, it } from "vitest"; | ||||||
|  | import * as i18n from "./i18n.js"; | ||||||
|  | import path from "path"; | ||||||
|  | import fs from "fs"; | ||||||
|  |  | ||||||
|  | describe("i18n", () => { | ||||||
|  |     it("frontend translations are valid JSON", () => { | ||||||
|  |         const translationDir = "src/public/translations"; | ||||||
|  |         const locales = i18n.getLocales(); | ||||||
|  |  | ||||||
|  |         for (const locale of locales) { | ||||||
|  |             const translationPath = path.join(translationDir, locale.id, "translation.json"); | ||||||
|  |             const translationFile = fs.readFileSync(translationPath, { encoding: "utf-8" }); | ||||||
|  |             expect(() => { | ||||||
|  |                 JSON.parse(translationFile); | ||||||
|  |             }, `JSON error while parsing locale '${locale.id}' at "${translationPath}"`).not.toThrow(); | ||||||
|  |         } | ||||||
|  |     }); | ||||||
|  | }); | ||||||
		Reference in New Issue
	
	Block a user