Skip to content

Commit

Permalink
update to latest lingui, remove copy of Trans
Browse files Browse the repository at this point in the history
  • Loading branch information
timofei-iatsenko committed Aug 31, 2023
1 parent 768c670 commit 088d04a
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 318 deletions.
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LinguiTransRscResolver {
...request,
request: request.context.issuerLayer === 'rsc'
// RSC Version without Context
? path.resolve('./src/i18n/Trans.tsx')
? path.resolve('./src/i18n/rsc-trans.tsx')
// Regular version
: '@lingui/react',
};
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
"lint": "next lint"
},
"dependencies": {
"@lingui/core": "^4.3.0",
"@lingui/macro": "^4.3.0",
"@lingui/react": "^4.3.0",
"@lingui/core": "^4.4.2",
"@lingui/macro": "^4.4.2",
"@lingui/react": "^4.4.2",
"@lingui/swc-plugin": "^4.0.4",
"@types/node": "20.4.5",
"@types/react": "18.2.17",
Expand All @@ -24,6 +24,6 @@
"typescript": "5.1.6"
},
"devDependencies": {
"@lingui/loader": "^4.3.0"
"@lingui/loader": "^4.4.2"
}
}
4 changes: 1 addition & 3 deletions src/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ export default async function Home({ params }) {
i18n,
);



return (
<main className={styles.main}>
<div className={styles.description}>
<Trans>Plural Test: How many developers?</Trans>

<LinguiProvider {...i18nSetupData}>
<ClientComponent></ClientComponent>
{/*<Switcher></Switcher>*/}
<Switcher></Switcher>
</LinguiProvider>

<p>
Expand Down
137 changes: 0 additions & 137 deletions src/i18n/Trans.tsx

This file was deleted.

123 changes: 0 additions & 123 deletions src/i18n/format.ts

This file was deleted.

14 changes: 14 additions & 0 deletions src/i18n/rsc-trans.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from "react"

import { getI18n } from './locale';
import { TransNoContext, TransProps } from '@lingui/react/server';

export function Trans(props: TransProps): React.ReactElement<any, any> | null {
const i18n = getI18n()

if (!i18n) {
throw new Error('Lingui for RSC is not initialized. Use `setI18n()` first in root of your RSC tree.');
}

return <TransNoContext {...props} lingui={{ i18n }}/>
}
Loading

0 comments on commit 088d04a

Please sign in to comment.