Skip to content

Commit

Permalink
style: Format all files through Prettier
Browse files Browse the repository at this point in the history
- Formatted all files through Prettier (`npx prettier . --write`).
  • Loading branch information
RoachxD committed Aug 12, 2023
1 parent 27315d8 commit acba27b
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 31 deletions.
6 changes: 5 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -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/',
]
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "build & test"
name: 'build & test'

on:
push:
Expand Down
34 changes: 18 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,21 @@ function App() {
return (
<I18nProvider i18n={i18n}>
<Text
message="Read the <link>documentation</link> for more info."
link={(text) => <a href="https://github.com/SanichKotikov/solid-i18n">{text}</a>}
message='Read the <link>documentation</link> for more info.'
link={(text) => (
<a href='https://github.com/SanichKotikov/solid-i18n'>{text}</a>
)}
/>
</I18nProvider>
)
);
}
```

### Plural Formatting

```typescript jsx
<Text
message="{count, plural, =0 {No items} one {One item} other {{count} items}}."
message='{count, plural, =0 {No items} one {One item} other {{count} items}}.'
count={19999}
/>
```
Expand All @@ -68,11 +70,7 @@ Note: use `{datetime, date}` for number or string values.
### Number Formatting

```typescript jsx
<Numeric
value={9.99}
numberStyle="currency"
currency="EUR"
/>
<Numeric value={9.99} numberStyle='currency' currency='EUR' />
```

### useI18n
Expand All @@ -86,8 +84,15 @@ function SomeComp() {
return (
<div>
<h1>{i18n.t('Page title')}</h1>
<div>{i18n.formatNumber(99999.9, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}</div>
<div>{i18n.formatDateTime(new Date(), { day: '2-digit', month: 'short' })}</div>
<div>
{i18n.formatNumber(99999.9, {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}
</div>
<div>
{i18n.formatDateTime(new Date(), { day: '2-digit', month: 'short' })}
</div>
</div>
);
}
Expand Down Expand Up @@ -131,12 +136,9 @@ const i18n = createI18n({
function App() {
return (
<I18nProvider i18n={i18n}>
<Text
message="Some value: {count, number, fraction}"
count={999}
/>
<Text message='Some value: {count, number, fraction}' count={999} />
</I18nProvider>
)
);
}
```

Expand Down
8 changes: 6 additions & 2 deletions src/components/Numeric.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ export interface NumericProps extends Omit<NumberOptions, 'style'> {

export function Numeric(props: Readonly<NumericProps>) {
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'];

Expand Down
10 changes: 7 additions & 3 deletions src/components/Text.tsx
Original file line number Diff line number Diff line change
@@ -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<TextProps>) {
const i18n = useI18n();
const [local, other] = splitProps(props, ['id', 'message', 'class']);

return <span class={local.class}>{i18n.t({ id: local.id, message: local.message }, other)}</span>;
return (
<span class={local.class}>
{i18n.t({ id: local.id, message: local.message }, other)}
</span>
);
}
4 changes: 3 additions & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export const I18nContext = createContext<Store<I18n>>();

export function useI18n(): Store<Readonly<I18n>> {
const context = useContext(I18nContext);
if (!context) throw new ReferenceError('I18nContext');
if (!context) {
throw new ReferenceError('I18nContext');
}

return context;
}
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ function cloneI18n(i18n: Readonly<I18n>): Readonly<I18n> {
};
}

export function createI18n(options: Omit<I18nOptions, 'formatTag'>): Readonly<I18n> {
export function createI18n(
options: Omit<I18nOptions, 'formatTag'>
): Readonly<I18n> {
const { i18n, subscribe } = create({ ...options, formatTag });

const [store, setStore] = createStore(cloneI18n(i18n));
Expand Down
8 changes: 2 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
"jsxImportSource": "solid-js",
"jsx": "preserve"
},
"include": [
"src"
],
"exclude": [
"node_modules"
]
"include": ["src"],
"exclude": ["node_modules"]
}

0 comments on commit acba27b

Please sign in to comment.