diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 420389d..6770ee9 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1,5 @@ -custom: [ 'https://money.yandex.ru/to/410013821917728/', 'https://www.paypal.me/cdrpro/' ] +custom: + [ + 'https://money.yandex.ru/to/410013821917728/', + 'https://www.paypal.me/cdrpro/', + ] diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 38cc1d6..c5400d6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: "build & test" +name: 'build & test' on: push: diff --git a/README.md b/README.md index 1ac502e..47bd477 100644 --- a/README.md +++ b/README.md @@ -29,11 +29,13 @@ function App() { return ( {text}} + message='Read the documentation for more info.' + link={(text) => ( + {text} + )} /> - ) + ); } ``` @@ -41,7 +43,7 @@ function App() { ```typescript jsx ``` @@ -68,11 +70,7 @@ Note: use `{datetime, date}` for number or string values. ### Number Formatting ```typescript jsx - + ``` ### useI18n @@ -86,8 +84,15 @@ function SomeComp() { return (

{i18n.t('Page title')}

-
{i18n.formatNumber(99999.9, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}
-
{i18n.formatDateTime(new Date(), { day: '2-digit', month: 'short' })}
+
+ {i18n.formatNumber(99999.9, { + minimumFractionDigits: 2, + maximumFractionDigits: 2, + })} +
+
+ {i18n.formatDateTime(new Date(), { day: '2-digit', month: 'short' })} +
); } @@ -131,12 +136,9 @@ const i18n = createI18n({ function App() { return ( - + - ) + ); } ``` diff --git a/src/components/Numeric.tsx b/src/components/Numeric.tsx index 5233134..d2a6d70 100644 --- a/src/components/Numeric.tsx +++ b/src/components/Numeric.tsx @@ -12,8 +12,12 @@ export interface NumericProps extends Omit { export function Numeric(props: Readonly) { const i18n = useI18n(); - - const [local, other] = splitProps(props, ['value', 'preset', 'numberStyle', 'class']); + const [local, other] = splitProps(props, [ + 'value', + 'preset', + 'numberStyle', + 'class', + ]); const options = mergeProps(other, { style: local.numberStyle }); const numberPreset = i18n.presets.number?.[local.preset ?? 'default']; diff --git a/src/components/Text.tsx b/src/components/Text.tsx index 97ffb95..8af89e1 100644 --- a/src/components/Text.tsx +++ b/src/components/Text.tsx @@ -1,12 +1,16 @@ -import { splitProps } from 'solid-js'; import type { I18nMessage, I18nValues } from 'i18n-mini/lib/types'; +import { splitProps } from 'solid-js'; import { useI18n } from '../context'; -export type TextProps = I18nMessage & I18nValues & { class?: string; }; +export type TextProps = I18nMessage & I18nValues & { class?: string }; export function Text(props: Readonly) { const i18n = useI18n(); const [local, other] = splitProps(props, ['id', 'message', 'class']); - return {i18n.t({ id: local.id, message: local.message }, other)}; + return ( + + {i18n.t({ id: local.id, message: local.message }, other)} + + ); } diff --git a/src/context.ts b/src/context.ts index 4510963..69ef5be 100644 --- a/src/context.ts +++ b/src/context.ts @@ -6,7 +6,9 @@ export const I18nContext = createContext>(); export function useI18n(): Store> { const context = useContext(I18nContext); - if (!context) throw new ReferenceError('I18nContext'); + if (!context) { + throw new ReferenceError('I18nContext'); + } return context; } diff --git a/src/index.ts b/src/index.ts index cd27675..828e9f5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -28,7 +28,9 @@ function cloneI18n(i18n: Readonly): Readonly { }; } -export function createI18n(options: Omit): Readonly { +export function createI18n( + options: Omit +): Readonly { const { i18n, subscribe } = create({ ...options, formatTag }); const [store, setStore] = createStore(cloneI18n(i18n)); diff --git a/tsconfig.json b/tsconfig.json index 55ad05a..dae3874 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -27,10 +27,6 @@ "jsxImportSource": "solid-js", "jsx": "preserve" }, - "include": [ - "src" - ], - "exclude": [ - "node_modules" - ] + "include": ["src"], + "exclude": ["node_modules"] }