@particle-network/connectkit
Version:
90 lines (87 loc) • 2.06 kB
JavaScript
"use client";
import {
en_US_default,
init_en_US
} from "./chunk-TVDFKXAV.mjs";
import {
init_ja_JP,
ja_JP_default
} from "./chunk-4YAFPODW.mjs";
import {
init_ko_KR,
ko_KR_default
} from "./chunk-NITEP4FF.mjs";
import {
init_zh_CN,
zh_CN_default
} from "./chunk-N5ZSWBVC.mjs";
import {
init_zh_TW,
zh_TW_default
} from "./chunk-D7QF5CYD.mjs";
import {
__esm
} from "./chunk-Y7A564BU.mjs";
// src/locales/index.tsx
function formatLocale(txt, ...values) {
const nodePlacer = "<></>";
const nodes = [];
const formatValue = txt.replace(/\{\d+\}/g, (match) => {
const index = parseInt(match.slice(1, -1), 10);
const value = values[index];
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || !value) {
return values[index]?.toString() ?? match;
}
nodes.push(value);
return nodePlacer;
});
if (nodes.length > 0) {
const strs = formatValue.split(nodePlacer);
const elements = [];
for (let i = 0; i < strs.length; i++) {
elements.push(strs[i]);
if (nodes[i]) {
elements.push(nodes[i]);
}
}
return elements.map((item) => item);
}
return formatValue;
}
var getLocale;
var init_locales = __esm({
"src/locales/index.tsx"() {
init_en_US();
init_ja_JP();
init_ko_KR();
init_zh_CN();
init_zh_TW();
getLocale = (lang) => {
switch (lang) {
case "ja-JP":
return ja_JP_default;
case "zh-CN":
return zh_CN_default;
case "zh-TW":
return zh_TW_default;
case "ko-KR":
return ko_KR_default;
default:
return en_US_default;
}
};
String.prototype.format = function(...values) {
const formatValue = this.replace(/\{\d+\}/g, (match) => {
const index = parseInt(match.slice(1, -1), 10);
return values[index]?.toString() ?? match;
});
return formatValue;
};
}
});
export {
getLocale,
formatLocale,
init_locales
};
//# sourceMappingURL=chunk-ZBMASWYL.mjs.map