@liam-public/i18n 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/index.cjs +33 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/package.json +36 -0
package/README.md
ADDED
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
translate: () => translate
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
function translate(text, language, fallbackLanguage) {
|
|
27
|
+
return text[language] || (fallbackLanguage ? text[fallbackLanguage] : void 0) || "";
|
|
28
|
+
}
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
translate
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type MultilingualText<Language extends string = string> =\n Readonly<Partial<Record<Language, string>>>\n\nexport function translate<Language extends string>(\n text: MultilingualText<Language>,\n language: Language,\n fallbackLanguage?: Language,\n): string {\n return text[language] || (fallbackLanguage ? text[fallbackLanguage] : undefined) || ''\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,SAAS,UACd,MACA,UACA,kBACQ;AACR,SAAO,KAAK,QAAQ,MAAM,mBAAmB,KAAK,gBAAgB,IAAI,WAAc;AACtF;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
type MultilingualText<Language extends string = string> = Readonly<Partial<Record<Language, string>>>;
|
|
2
|
+
declare function translate<Language extends string>(text: MultilingualText<Language>, language: Language, fallbackLanguage?: Language): string;
|
|
3
|
+
|
|
4
|
+
export { type MultilingualText, translate };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
type MultilingualText<Language extends string = string> = Readonly<Partial<Record<Language, string>>>;
|
|
2
|
+
declare function translate<Language extends string>(text: MultilingualText<Language>, language: Language, fallbackLanguage?: Language): string;
|
|
3
|
+
|
|
4
|
+
export { type MultilingualText, translate };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type MultilingualText<Language extends string = string> =\n Readonly<Partial<Record<Language, string>>>\n\nexport function translate<Language extends string>(\n text: MultilingualText<Language>,\n language: Language,\n fallbackLanguage?: Language,\n): string {\n return text[language] || (fallbackLanguage ? text[fallbackLanguage] : undefined) || ''\n}\n"],"mappings":";AAGO,SAAS,UACd,MACA,UACA,kBACQ;AACR,SAAO,KAAK,QAAQ,MAAM,mBAAmB,KAAK,gBAAgB,IAAI,WAAc;AACtF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@liam-public/i18n",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Universal typed multilingual text helpers.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"liamCompatibility": {
|
|
7
|
+
"runtime": [
|
|
8
|
+
"universal"
|
|
9
|
+
],
|
|
10
|
+
"framework": [
|
|
11
|
+
"agnostic"
|
|
12
|
+
]
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public",
|
|
28
|
+
"registry": "https://registry.npmjs.org/"
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsup src/index.ts --format esm --dts --sourcemap",
|
|
32
|
+
"clean": "rm -rf dist",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"typecheck": "tsc --noEmit"
|
|
35
|
+
}
|
|
36
|
+
}
|