create-fate 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/create-fate.mjs +30 -1
- package/package.json +1 -1
- package/templates/fate/cloudflare/README.md +11 -0
- package/templates/fate/cloudflare/client/package.json +10 -5
- package/templates/fate/cloudflare/client/pages/layout.tsx +2 -16
- package/templates/fate/cloudflare/client/src/lib/AvailableLanguages.tsx +3 -3
- package/templates/fate/cloudflare/client/src/lib/LocaleContext.tsx +61 -0
- package/templates/fate/cloudflare/client/src/ui/LocaleSwitcher.tsx +26 -44
- package/templates/fate/cloudflare/client/start.mjs +11 -0
- package/templates/fate/cloudflare/client/translations/{de_DE.json → de-DE.json} +56 -113
- package/templates/fate/{graphql/client/translations/ja_JP.json → cloudflare/client/translations/ja-JP.json} +56 -113
- package/templates/fate/cloudflare/client/vite.config.ts +1 -1
- package/templates/fate/cloudflare/server/src/lib/auth.ts +0 -2
- package/templates/fate/cloudflare/server/tsconfig.json +1 -1
- package/templates/fate/cloudflare/tsconfig.json +1 -1
- package/templates/fate/drizzle/README.md +11 -0
- package/templates/fate/drizzle/client/package.json +9 -5
- package/templates/fate/drizzle/client/pages/layout.tsx +2 -16
- package/templates/fate/drizzle/client/src/lib/AvailableLanguages.tsx +3 -3
- package/templates/fate/drizzle/client/src/lib/LocaleContext.tsx +61 -0
- package/templates/fate/drizzle/client/src/ui/LocaleSwitcher.tsx +26 -44
- package/templates/fate/drizzle/client/start.mjs +11 -0
- package/templates/fate/{graphql/client/translations/de_DE.json → drizzle/client/translations/de-DE.json} +56 -113
- package/templates/fate/{cloudflare/client/translations/ja_JP.json → drizzle/client/translations/ja-JP.json} +56 -113
- package/templates/fate/drizzle/client/vite.config.ts +1 -1
- package/templates/fate/graphql/README.md +11 -0
- package/templates/fate/graphql/client/package.json +9 -5
- package/templates/fate/graphql/client/pages/layout.tsx +2 -16
- package/templates/fate/graphql/client/src/lib/AvailableLanguages.tsx +3 -3
- package/templates/fate/graphql/client/src/lib/LocaleContext.tsx +61 -0
- package/templates/fate/graphql/client/src/ui/LocaleSwitcher.tsx +26 -44
- package/templates/fate/graphql/client/start.mjs +11 -0
- package/templates/fate/{drizzle/client/translations/de_DE.json → graphql/client/translations/de-DE.json} +56 -113
- package/templates/fate/{http/client/translations/ja_JP.json → graphql/client/translations/ja-JP.json} +56 -113
- package/templates/fate/graphql/client/vite.config.ts +1 -1
- package/templates/fate/graphql-client/README.md +9 -0
- package/templates/fate/graphql-client/_gitignore +3 -0
- package/templates/fate/graphql-client/package.json +9 -2
- package/templates/fate/graphql-client/pages/index.tsx +13 -5
- package/templates/fate/graphql-client/pages/layout.tsx +22 -15
- package/templates/fate/graphql-client/src/lib/AvailableLanguages.tsx +5 -0
- package/templates/fate/graphql-client/src/lib/LocaleContext.tsx +61 -0
- package/templates/fate/graphql-client/src/ui/LocaleSwitcher.tsx +34 -0
- package/templates/fate/graphql-client/translations/de-DE.json +225 -0
- package/templates/fate/graphql-client/translations/ja-JP.json +225 -0
- package/templates/fate/graphql-client/vite.config.ts +2 -0
- package/templates/fate/http/README.md +11 -0
- package/templates/fate/http/client/package.json +9 -5
- package/templates/fate/http/client/pages/layout.tsx +2 -16
- package/templates/fate/http/client/src/lib/AvailableLanguages.tsx +3 -3
- package/templates/fate/http/client/src/lib/LocaleContext.tsx +61 -0
- package/templates/fate/http/client/src/ui/LocaleSwitcher.tsx +26 -44
- package/templates/fate/http/client/start.mjs +11 -0
- package/templates/fate/http/client/translations/{de_DE.json → de-DE.json} +56 -113
- package/templates/fate/{drizzle/client/translations/ja_JP.json → http/client/translations/ja-JP.json} +56 -113
- package/templates/fate/http/client/vite.config.ts +1 -1
- package/templates/fate/prisma/README.md +11 -0
- package/templates/fate/prisma/client/package.json +9 -5
- package/templates/fate/prisma/client/pages/layout.tsx +2 -16
- package/templates/fate/prisma/client/src/lib/AvailableLanguages.tsx +3 -3
- package/templates/fate/prisma/client/src/lib/LocaleContext.tsx +61 -0
- package/templates/fate/prisma/client/src/ui/LocaleSwitcher.tsx +26 -44
- package/templates/fate/prisma/client/start.mjs +11 -0
- package/templates/fate/prisma/client/translations/de-DE.json +632 -0
- package/templates/fate/prisma/client/translations/ja-JP.json +632 -0
- package/templates/fate/prisma/client/vite.config.ts +1 -1
- package/templates/fate/void/README.md +9 -0
- package/templates/fate/void/_gitignore +3 -0
- package/templates/fate/void/middleware/01.shared.ts +3 -0
- package/templates/fate/void/package.json +9 -2
- package/templates/fate/void/pages/index.tsx +22 -10
- package/templates/fate/void/pages/layout.tsx +22 -19
- package/templates/fate/void/pages/login.tsx +22 -18
- package/templates/fate/void/pages/search.tsx +18 -4
- package/templates/fate/void/src/lib/AvailableLanguages.tsx +5 -0
- package/templates/fate/void/src/lib/LocaleContext.tsx +61 -0
- package/templates/fate/void/src/ui/CategoryCard.tsx +22 -4
- package/templates/fate/void/src/ui/CreatePost.tsx +12 -7
- package/templates/fate/void/src/ui/Error.tsx +4 -2
- package/templates/fate/void/src/ui/EventCard.tsx +18 -5
- package/templates/fate/void/src/ui/Header.tsx +10 -4
- package/templates/fate/void/src/ui/LocaleSwitcher.tsx +34 -0
- package/templates/fate/void/src/ui/PostCard.tsx +29 -14
- package/templates/fate/void/src/ui/UserCard.tsx +15 -8
- package/templates/fate/void/translations/de-DE.json +863 -0
- package/templates/fate/void/translations/ja-JP.json +863 -0
- package/templates/fate/void/vite.config.ts +2 -0
- package/templates/fate/prisma/client/translations/de_DE.json +0 -689
- package/templates/fate/prisma/client/translations/ja_JP.json +0 -689
|
@@ -1,52 +1,34 @@
|
|
|
1
|
-
import { VStack } from '@nkzw/stack';
|
|
2
|
-
import { cx } from 'class-variance-authority';
|
|
3
1
|
import { useLocaleContext } from 'fbtee';
|
|
4
|
-
import {
|
|
2
|
+
import { startTransition } from 'react';
|
|
5
3
|
import AvailableLanguages from '../lib/AvailableLanguages.tsx';
|
|
6
|
-
import { Button } from './Button.tsx';
|
|
7
|
-
import Card from './Card.tsx';
|
|
8
4
|
|
|
9
5
|
export default function LocaleSwitcher() {
|
|
10
|
-
const { locale
|
|
11
|
-
|
|
6
|
+
const { locale, localeChangeIsPending, setLocale } = useLocaleContext();
|
|
12
7
|
return (
|
|
13
|
-
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
8
|
+
<label className="inline-flex items-center gap-2 text-sm">
|
|
9
|
+
<span className="sr-only">
|
|
10
|
+
<fbt desc="Locale switcher button">Change Language</fbt>
|
|
11
|
+
</span>
|
|
12
|
+
<select
|
|
13
|
+
className="rounded-md border border-gray-300 bg-background px-2 py-1 text-foreground"
|
|
14
|
+
disabled={localeChangeIsPending}
|
|
15
|
+
onChange={(event) => {
|
|
16
|
+
const nextLocale = event.target.value;
|
|
17
|
+
try {
|
|
18
|
+
localStorage.setItem('fbtee:locale', nextLocale);
|
|
19
|
+
} catch {
|
|
20
|
+
// Changing the language still works without browser storage.
|
|
21
|
+
}
|
|
22
|
+
startTransition(() => setLocale(nextLocale));
|
|
23
|
+
}}
|
|
24
|
+
value={locale}
|
|
26
25
|
>
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
asChild
|
|
35
|
-
className={cx(
|
|
36
|
-
'transition-background border-slate-200 bg-transparent duration-150 hover:border-slate-300 hover:bg-slate-200 dark:hover:bg-slate-900 dark:text-white active:py-2',
|
|
37
|
-
{
|
|
38
|
-
'bg-slate-100 dark:bg-slate-900': currentLocale === locale,
|
|
39
|
-
},
|
|
40
|
-
)}
|
|
41
|
-
key={locale}
|
|
42
|
-
size="sm"
|
|
43
|
-
variant="outline"
|
|
44
|
-
>
|
|
45
|
-
<a className="w-full flex-1 cursor-pointer p-2">{name}</a>
|
|
46
|
-
</Button>
|
|
47
|
-
))}
|
|
48
|
-
</VStack>
|
|
49
|
-
</Card>
|
|
50
|
-
</>
|
|
26
|
+
{[...AvailableLanguages].map(([value, name]) => (
|
|
27
|
+
<option key={value} value={value}>
|
|
28
|
+
{name}
|
|
29
|
+
</option>
|
|
30
|
+
))}
|
|
31
|
+
</select>
|
|
32
|
+
</label>
|
|
51
33
|
);
|
|
52
34
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import process from 'node:process';
|
|
3
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
4
|
+
|
|
5
|
+
const dist = new URL('./dist/', import.meta.url);
|
|
6
|
+
// Void's Node renderer reads this manifest to emit client scripts and styles.
|
|
7
|
+
globalThis.__VITE_MANIFEST__ = JSON.parse(
|
|
8
|
+
readFileSync(new URL('client/.vite/manifest.json', dist), 'utf8'),
|
|
9
|
+
);
|
|
10
|
+
process.chdir(fileURLToPath(dist));
|
|
11
|
+
await import(new URL('ssr/index.js', dist).href);
|