Skip to content

Commit

Permalink
added contents, revert no-comments, update module/export/types order …
Browse files Browse the repository at this point in the history
…in package.json
  • Loading branch information
m10rten committed Aug 18, 2024
1 parent 6a7d3d6 commit 61529fc
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
28 changes: 28 additions & 0 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ To use this package, install with npm:
npm install i4n
```

## Contents

- [i4n](#i4n)
- [Installation](#installation)
- [Usage](#usage)
- [Init](#init)
- [Functions](#functions)
- [`t`](#t)
- [Fallback keys](#fallback-keys)
- [Fallback language](#fallback-language)
- [`switch`](#switch)
- [Templates](#templates)
- [`I4nException`](#i4nexception)
<!-- - [Examples](#examples) -->

## Usage

To get started with translating, import the I4n class:
Expand Down Expand Up @@ -221,3 +236,16 @@ In that case, the module will throw a `I4nException` error.
The same error is thrown when (also forced) switching to a language that is not in the translations.

These errors will need to be catched if you need to force some functionality, but this is strongly discouraged because it may break any end-user experience.

<!-- ## Examples
To showcase the `i4n` package, there have been made several examples.
The following examples are present in this repository:
- [**Nextjs.org**](https://nextjs.org/) - [examples/i4n-next](../examples/i4n-next/README.md)
- [**Hono.dev**](https://hono.dev/) - [examples/i4n-hono](../examples/i4n-hono/README.md) -->

<hr />

[back to top](#i4n)
20 changes: 11 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "i4n",
"version": "0.3.1",
"version": "0.3.2",
"description": "Lightweight, Zero dependencies, Typesafe and Simple to use translations for TypeScript.",
"private": false,
"types": "./dist/index.d.ts",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"homepage": "https://github.com/m10rten/i4n#readme",
"repository": {
"type": "git",
Expand Down Expand Up @@ -54,22 +54,24 @@
},
"exports": {
".": {
"import": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
"import": "./dist/index.mjs"
},
"./i4n": {
"import": "./dist/i4n.mjs",
"types": "./dist/i4n.d.ts",
"require": "./dist/i4n.js",
"types": "./dist/i4n.d.ts"
"import": "./dist/i4n.mjs"
},
"./errors": {
"import": "./dist/errors.mjs",
"types": "./dist/errors.d.ts",
"require": "./dist/errors.js",
"types": "./dist/errors.d.ts"
"import": "./dist/errors.mjs"
},
"./types": {
"types": "./dist/types.d.ts"
"types": "./dist/types.d.ts",
"require": "./dist/types.js",
"import": "./dist/types.mjs"
},
"./package.json": "./package.json"
},
Expand Down
2 changes: 1 addition & 1 deletion src/i4n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class I4n<T extends Record<string, unknown>, L extends keyof T & string>
* @returns string or undefined based on the path you provide.
*/
public t<P extends Path<T[L], L>, P2 extends Path<T[L], L>, V extends Value<T[L], L, P>>(
path: P | string | [P | (string & {})] | [P | (string & {}), P2 | (string & {})],
path: P | (string & {}) | [P | (string & {})] | [P | (string & {}), P2 | (string & {})],
): V;

/**
Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"strictNullChecks": true,
"noImplicitAny": true,
"noUncheckedIndexedAccess": true,
"allowUnreachableCode": false,
"removeComments": true
"allowUnreachableCode": false
},
"exclude": ["node_modules", "dist"]
}

0 comments on commit 61529fc

Please sign in to comment.