Skip to content

Commit

Permalink
docs: update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
aymericzip committed Apr 25, 2024
1 parent 5ea88dd commit db981de
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ export type EnumerationContent<Content> = Partial<QuantityContent<Content>> &
*
* Usage:
*
* ```ts
* const content = enu({
* '<=-2.3': 'You have less than -2.3',
* '<1': 'You have less than one',
* '2': 'You have two',
* '>=3': 'You have three or more',
* });
* ```
*
* The order of the keys will define the priority of the content.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,25 @@ type Key = keyof QuantityContent<string>;
*
* Usage:
*
* ```ts
* const content = getEnumerationContent({
* '<=-2.3': 'You have less than -2.3',
* '<1': 'You have less than one',
* '2': 'You have two',
* '>=3': 'You have three or more',
* },
* 2);
* }, 2);
* // 'You have two'
* ```
*
* The order of the keys will define the priority of the content.
*
* ```ts
* const content = getEnumerationContent({
* '<4': 'You have less than four',
* '2': 'You have two',
* });
* '<4': 'You have less than four',
* '2': 'You have two',
* }, 2);
* // 'You have less than four'
* ```
*
*/
export const getEnumerationContent = <Content>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ type GetTranslationContent = <Content = string>(
*
* Usage:
*
* ```ts
* const content = getTranslationContent({
* en: 'Hello',
* fr: 'Bonjour',
* },
* 'fr');
* en: 'Hello',
* fr: 'Bonjour',
* }, 'fr');
* // 'Bonjour'
* ```
*
* Using TypeScript:
* - this function will require each locale to be defined if defined in the project configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ const { defaultLocale } = intlayerConfiguration.internationalization;
*
* Usage:
*
* ```ts
* translation<string>({
* "en": "Hello",
* "fr": "Bonjour",
* // ... any other available locale
* })
* ```
*
* Using TypeScript:
* - this function require each locale to be defined if defined in the project configuration.
Expand Down
2 changes: 2 additions & 0 deletions packages/next-intlayer/src/middleware/intlayerMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ const {
*
* // ./src/middleware.ts
*
* ```ts
* export { intlayerMiddleware as middleware } from '@intlayer/next/middleware';
*
* // applies this middleware only to files in the app directory
* export const config = {
* matcher: '/((?!api|static|.*\\..*|_next).*)',
* };
* ```
*
*/
export const intlayerMiddleware = (request: NextRequest): NextResponse => {
Expand Down
2 changes: 2 additions & 0 deletions packages/next-intlayer/src/server/withIntlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ type WebpackParams = Parameters<NextJsWebpackConfig>;
*
* Usage:
*
* ```ts
* // next.config.js
* export default withIntlayer(nextConfig)
* ```
*
*/
export const withIntlayer =
Expand Down
11 changes: 6 additions & 5 deletions packages/react-intlayer/src/client/useTraduction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import { IntlayerClientContext } from './IntlayerClientProvider';
*
* Usage:
*
* const content = getTranslation<string>({
* en: 'Hello',
* fr: 'Bonjour',
* },
* 'fr');
* ```tsx
* const content = useTraduction<string>({
* en: 'Hello',
* fr: 'Bonjour',
* }, 'fr');
* // 'Bonjour'
* ```
*
* Using TypeScript:
* - this function will require each locale to be defined if defined in the project configuration.
Expand Down
13 changes: 8 additions & 5 deletions packages/react-intlayer/src/getEnumeration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,25 @@ import { contentRender } from './ContentEditor/contentRender';
*
* Usage:
*
* ```ts
* const content = getEnumeration({
* '<=-2.3': 'You have less than -2.3',
* '<1': 'You have less than one',
* '2': 'You have two',
* '>=3': 'You have three or more',
* },
* 2);
* }, 2);
* // 'You have two'
* ```
*
* The order of the keys will define the priority of the content.
*
* ```ts
* const content = getEnumeration({
* '<4': 'You have less than four',
* '2': 'You have two',
* });
* '<4': 'You have less than four',
* '2': 'You have two',
* }, 2);
* // 'You have less than four'
* ```
*
*/
export const getEnumeration = <Content>(
Expand Down
5 changes: 3 additions & 2 deletions packages/react-intlayer/src/getTranslation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import { contentRender } from './ContentEditor/contentRender';
*
* Usage:
*
* ```ts
* const content = getTranslation<string>({
* en: 'Hello',
* fr: 'Bonjour',
* },
* 'fr');
* }, 'fr');
* // 'Bonjour'
* ```
*
* Using TypeScript:
* - this function will require each locale to be defined if defined in the project configuration.
Expand Down
7 changes: 4 additions & 3 deletions packages/react-intlayer/src/server/useTraduction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import { getServerContext } from './serverContext';
*
* Usage:
*
* const content = getTranslation<string>({
* ```ts
* const content = useTraduction<string>({
* en: 'Hello',
* fr: 'Bonjour',
* },
* 'fr');
* }, 'fr');
* // 'Bonjour'
* ```
*
* Using TypeScript:
* - this function will require each locale to be defined if defined in the project configuration.
Expand Down

0 comments on commit db981de

Please sign in to comment.