|
1 | | -import Image from "next/image"; |
2 | 1 | import { Counter } from "@/components/counter"; |
3 | 2 | import { LocaleSwitcher } from "@lingo.dev/_compiler/react"; |
4 | 3 | import Link from "next/link"; |
5 | 4 | import { CounterServerChild } from "@/components/counterServerChild"; |
6 | 5 |
|
| 6 | +const externalText = <>External text</>; |
| 7 | + |
7 | 8 | export default function Home() { |
| 9 | + const text = "Hello World"; |
| 10 | + const translatableText = <>Hello World</>; |
| 11 | + const translatableMixedContextFragment = ( |
| 12 | + <> |
| 13 | + <b>Mixed</b> content <i>fragment</i> |
| 14 | + </> |
| 15 | + ); |
| 16 | + |
8 | 17 | return ( |
9 | | - <div className="flex min-h-screen items-center justify-center bg-zinc-50 font-sans dark:bg-black"> |
10 | | - <LocaleSwitcher |
11 | | - locales={[ |
12 | | - { code: "en", label: "English" }, |
13 | | - { code: "es", label: "Spanish" }, |
14 | | - { code: "de", label: "Deutsch" }, |
15 | | - { code: "fr", label: "Français" }, |
16 | | - ]} |
17 | | - /> |
18 | | - <main className="flex min-h-screen w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start"> |
19 | | - <Image |
20 | | - className="dark:invert" |
21 | | - src="/next.svg" |
22 | | - alt="Next.js logo" |
23 | | - width={100} |
24 | | - height={20} |
25 | | - priority |
| 18 | + <main className="flex w-full min-h-screen flex-col items-center bg-white dark:bg-black sm:items-start"> |
| 19 | + <header className="flex justify-between p-10 w-full"> |
| 20 | + <span>Lingo.dev compiler Next demo</span> |
| 21 | + <nav> |
| 22 | + <Link href="/test">Test</Link> |
| 23 | + </nav> |
| 24 | + <LocaleSwitcher |
| 25 | + locales={[ |
| 26 | + { code: "en", label: "English" }, |
| 27 | + { code: "es", label: "Spanish" }, |
| 28 | + { code: "de", label: "Deutsch" }, |
| 29 | + { code: "fr", label: "Français" }, |
| 30 | + ]} |
26 | 31 | /> |
27 | | - <div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left"> |
28 | | - <h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50"> |
29 | | - To get started, edit the page.tsx file |
30 | | - </h1> |
31 | | - <p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400"> |
32 | | - Looking for a starting points or more instructions? Head over to{" "} |
33 | | - <a |
34 | | - href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app" |
35 | | - className="font-medium text-zinc-950 dark:text-zinc-50" |
36 | | - > |
37 | | - Templates |
38 | | - </a>{" "} |
39 | | - or the{" "} |
40 | | - <a |
41 | | - href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app" |
42 | | - className="font-medium text-zinc-950 dark:text-zinc-50" |
43 | | - > |
44 | | - Learning |
45 | | - </a>{" "} |
46 | | - center. |
47 | | - </p> |
| 32 | + </header> |
| 33 | + <div className="flex w-full grow flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start"> |
| 34 | + <h1 className="text-4xl font-bold mb-4"> |
| 35 | + Welcome to Lingo.dev compiler demo |
| 36 | + </h1> |
| 37 | + <p className="mb-8"> |
| 38 | + It automatically extract text from your JSX and translate it to other |
| 39 | + languages. <br /> |
| 40 | + It supports both server and client components. |
| 41 | + </p> |
| 42 | + <div className="my-2"> |
| 43 | + <Counter> |
| 44 | + <CounterServerChild /> |
| 45 | + </Counter> |
| 46 | + </div> |
| 47 | + <div> |
| 48 | + Text inserted as an <code>{"{expression}"}</code> is not translated:{" "} |
| 49 | + {text} |
| 50 | + </div> |
| 51 | + <div> |
| 52 | + To translate it you have to wrap it into the {translatableText} |
| 53 | + </div> |
| 54 | + <div> |
| 55 | + Text external to the component is not translated: {externalText} |
48 | 56 | </div> |
49 | | - <div>Test2</div> |
50 | | - <Link href="/test">Test</Link> |
51 | | - <Counter> |
52 | | - <CounterServerChild /> |
53 | | - </Counter> |
54 | | - <div className="flex flex-col gap-4 text-base font-medium sm:flex-row"> |
55 | | - <a |
56 | | - className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-[158px]" |
57 | | - href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app" |
58 | | - target="_blank" |
59 | | - rel="noopener noreferrer" |
60 | | - > |
61 | | - <Image |
62 | | - className="dark:invert" |
63 | | - src="/vercel.svg" |
64 | | - alt="Vercel logomark" |
65 | | - width={16} |
66 | | - height={16} |
67 | | - /> |
68 | | - Deploy Now |
69 | | - </a> |
70 | | - <a |
71 | | - className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]" |
72 | | - href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app" |
73 | | - target="_blank" |
74 | | - rel="noopener noreferrer" |
75 | | - > |
76 | | - Documentation |
77 | | - </a> |
| 57 | + <div> |
| 58 | + Content that has text and other tags inside will br translated as a |
| 59 | + single entity: {translatableMixedContextFragment} |
78 | 60 | </div> |
79 | | - </main> |
80 | | - </div> |
| 61 | + </div> |
| 62 | + </main> |
81 | 63 | ); |
82 | 64 | } |
0 commit comments