mirror of
https://github.com/Ku6epXBOCTuK/easy-png-tools.git
synced 2026-09-14 21:46:35 +00:00
style: fix formatting via prettier
This commit is contained in:
+17
-7
@@ -1,9 +1,12 @@
|
||||
import { getMergedDict } from './locale.svelte';
|
||||
import { getMergedDict } from "./locale.svelte";
|
||||
|
||||
export function interpolate(template: string, vars?: Record<string, string | number>): string {
|
||||
export function interpolate(
|
||||
template: string,
|
||||
vars?: Record<string, string | number>,
|
||||
): string {
|
||||
if (!vars) return template;
|
||||
return template.replace(/\{(\w+)\}/g, (match, name: string) =>
|
||||
name in vars ? String(vars[name]) : match
|
||||
name in vars ? String(vars[name]) : match,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,14 +14,21 @@ export function interpolate(template: string, vars?: Record<string, string | num
|
||||
* Перевод по точечному пути вида 'header.workspace' или 'errors.ERR_BAD_HEX'.
|
||||
* Сначала активная локаль, затем базовая; если ключа нет нигде — возвращается сам путь.
|
||||
*/
|
||||
export function t(path: string, vars?: Record<string, string | number>): string {
|
||||
export function t(
|
||||
path: string,
|
||||
vars?: Record<string, string | number>,
|
||||
): string {
|
||||
let node: unknown = getMergedDict();
|
||||
for (const part of path.split('.')) {
|
||||
if (node && typeof node === 'object' && part in (node as Record<string, unknown>)) {
|
||||
for (const part of path.split(".")) {
|
||||
if (
|
||||
node &&
|
||||
typeof node === "object" &&
|
||||
part in (node as Record<string, unknown>)
|
||||
) {
|
||||
node = (node as Record<string, unknown>)[part];
|
||||
} else {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
return typeof node === 'string' ? interpolate(node, vars) : path;
|
||||
return typeof node === "string" ? interpolate(node, vars) : path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user