Skip to content

Commit f164c50

Browse files
ci: apply automated fixes
1 parent 7658eed commit f164c50

21 files changed

Lines changed: 228 additions & 241 deletions

File tree

‎examples/react/i18n-paraglide/README.md‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,39 +76,39 @@ export const Route = createRootRoute({
7676
If you don't want to miss any translated path, you can create a `createTranslatedPathnames` function and pass it to the vite plugin.
7777

7878
```ts
79-
import { Locale } from "@/paraglide/runtime";
80-
import { FileRoutesByTo } from "../routeTree.gen";
79+
import { Locale } from '@/paraglide/runtime'
80+
import { FileRoutesByTo } from '../routeTree.gen'
8181

82-
type RoutePath = keyof FileRoutesByTo;
82+
type RoutePath = keyof FileRoutesByTo
8383

84-
const excludedPaths = ["admin", "docs", "api"] as const;
84+
const excludedPaths = ['admin', 'docs', 'api'] as const
8585

8686
type PublicRoutePath = Exclude<
8787
RoutePath,
8888
`${string}${(typeof excludedPaths)[number]}${string}`
89-
>;
89+
>
9090

9191
type TranslatedPathname = {
92-
pattern: string;
93-
localized: Array<[Locale, string]>;
94-
};
92+
pattern: string
93+
localized: Array<[Locale, string]>
94+
}
9595

9696
function toUrlPattern(path: string) {
9797
return (
9898
path
9999
// catch-all
100-
.replace(/\/\$$/, "/:path(.*)?")
100+
.replace(/\/\$$/, '/:path(.*)?')
101101
// optional parameters: {-$param}
102-
.replace(/\{-\$([a-zA-Z0-9_]+)\}/g, ":$1?")
102+
.replace(/\{-\$([a-zA-Z0-9_]+)\}/g, ':$1?')
103103
// named parameters: $param
104-
.replace(/\$([a-zA-Z0-9_]+)/g, ":$1")
104+
.replace(/\$([a-zA-Z0-9_]+)/g, ':$1')
105105
// remove trailing slash
106-
.replace(/\/+$/, "")
107-
);
106+
.replace(/\/+$/, '')
107+
)
108108
}
109109

110110
function createTranslatedPathnames(
111-
input: Record<PublicRoutePath, Record<Locale, string>>
111+
input: Record<PublicRoutePath, Record<Locale, string>>,
112112
): TranslatedPathname[] {
113113
return Object.entries(input).map(([pattern, locales]) => ({
114114
pattern: toUrlPattern(pattern),
@@ -117,21 +117,21 @@ function createTranslatedPathnames(
117117
[locale as Locale, `/${locale}${toUrlPattern(path)}`] satisfies [
118118
Locale,
119119
string,
120-
]
120+
],
121121
),
122-
}));
122+
}))
123123
}
124124

125125
export const translatedPathnames = createTranslatedPathnames({
126-
"/": {
127-
en: "/",
128-
de: "/",
126+
'/': {
127+
en: '/',
128+
de: '/',
129129
},
130-
"/about": {
131-
en: "/about",
132-
de: "/ueber",
130+
'/about': {
131+
en: '/about',
132+
de: '/ueber',
133133
},
134-
});
134+
})
135135
```
136136

137137
And import into the Paraglide Vite plguin.
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
{
22
"$schema": "https://inlang.com/schema/project-settings",
33
"baseLocale": "en",
4-
"locales": [
5-
"en",
6-
"de"
7-
],
4+
"locales": ["en", "de"],
85
"modules": [
96
"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@4/dist/index.js",
107
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@2/dist/index.js"
118
],
129
"plugin.inlang.messageFormat": {
1310
"pathPattern": "./messages/{locale}.json"
1411
}
15-
}
12+
}
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { StrictMode } from "react";
2-
import ReactDOM from "react-dom/client";
3-
import { RouterProvider, createRouter } from "@tanstack/react-router";
4-
import "./styles.css";
1+
import { StrictMode } from 'react'
2+
import ReactDOM from 'react-dom/client'
3+
import { RouterProvider, createRouter } from '@tanstack/react-router'
4+
import './styles.css'
55
// Import the generated route tree
6-
import { routeTree } from "./routeTree.gen";
7-
import { deLocalizeUrl, localizeUrl } from "./paraglide/runtime.js";
6+
import { routeTree } from './routeTree.gen'
7+
import { deLocalizeUrl, localizeUrl } from './paraglide/runtime.js'
88

99
// Create a new router instance
1010
const router = createRouter({
1111
routeTree,
1212
context: {},
13-
defaultPreload: "intent",
13+
defaultPreload: 'intent',
1414
scrollRestoration: true,
1515
defaultStructuralSharing: true,
1616
defaultPreloadStaleTime: 0,
@@ -19,22 +19,22 @@ const router = createRouter({
1919
input: ({ url }) => deLocalizeUrl(url),
2020
output: ({ url }) => localizeUrl(url),
2121
},
22-
});
22+
})
2323

2424
// Register the router instance for type safety
25-
declare module "@tanstack/react-router" {
25+
declare module '@tanstack/react-router' {
2626
interface Register {
27-
router: typeof router;
27+
router: typeof router
2828
}
2929
}
3030

3131
// Render the app
32-
const rootElement = document.getElementById("app");
32+
const rootElement = document.getElementById('app')
3333
if (rootElement && !rootElement.innerHTML) {
34-
const root = ReactDOM.createRoot(rootElement);
34+
const root = ReactDOM.createRoot(rootElement)
3535
root.render(
3636
<StrictMode>
3737
<RouterProvider router={router} />
38-
</StrictMode>
39-
);
38+
</StrictMode>,
39+
)
4040
}

‎examples/react/i18n-paraglide/src/routes/__root.tsx‎

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
import {
2-
Link,
3-
Outlet,
4-
createRootRoute,
5-
redirect,
6-
} from "@tanstack/react-router";
1+
import { Link, Outlet, createRootRoute, redirect } from '@tanstack/react-router'
72
import {
83
getLocale,
94
locales,
105
setLocale,
116
shouldRedirect,
12-
} from "@/paraglide/runtime";
13-
import { m } from "@/paraglide/messages";
7+
} from '@/paraglide/runtime'
8+
import { m } from '@/paraglide/messages'
149

1510
export const Route = createRootRoute({
1611
beforeLoad: async () => {
17-
document.documentElement.setAttribute("lang", getLocale());
12+
document.documentElement.setAttribute('lang', getLocale())
1813

19-
const decision = await shouldRedirect({ url: window.location.href });
14+
const decision = await shouldRedirect({ url: window.location.href })
2015

2116
if (decision.redirectUrl) {
22-
throw redirect({ href: decision.redirectUrl.href });
17+
throw redirect({ href: decision.redirectUrl.href })
2318
}
2419
},
2520
component: () => (
@@ -29,7 +24,7 @@ export const Route = createRootRoute({
2924
<Link
3025
to="/"
3126
activeProps={{
32-
className: "font-bold",
27+
className: 'font-bold',
3328
}}
3429
activeOptions={{ exact: true }}
3530
>
@@ -39,7 +34,7 @@ export const Route = createRootRoute({
3934
<Link
4035
to="/about"
4136
activeProps={{
42-
className: "font-bold",
37+
className: 'font-bold',
4338
}}
4439
>
4540
{m.about_page()}
@@ -67,4 +62,4 @@ export const Route = createRootRoute({
6762
</div>
6863
</>
6964
),
70-
});
65+
})
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { m } from "@/paraglide/messages";
2-
import { createFileRoute } from "@tanstack/react-router";
1+
import { m } from '@/paraglide/messages'
2+
import { createFileRoute } from '@tanstack/react-router'
33

4-
export const Route = createFileRoute("/about")({
4+
export const Route = createFileRoute('/about')({
55
component: RouteComponent,
6-
});
6+
})
77

88
function RouteComponent() {
9-
return <div>{m.hello_about()}</div>;
9+
return <div>{m.hello_about()}</div>
1010
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { createFileRoute } from "@tanstack/react-router";
2-
import { m } from "@/paraglide/messages";
1+
import { createFileRoute } from '@tanstack/react-router'
2+
import { m } from '@/paraglide/messages'
33

4-
export const Route = createFileRoute("/")({
4+
export const Route = createFileRoute('/')({
55
component: App,
6-
});
6+
})
77

88
function App() {
99
return (
1010
<div>
1111
<p>
1212
{m.example_message({
13-
username: "TanStack Router!",
13+
username: 'TanStack Router!',
1414
})}
1515
</p>
1616
</div>
17-
);
17+
)
1818
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
@import "tailwindcss";
1+
@import 'tailwindcss';
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1-
import { defineConfig } from "vite";
2-
import viteReact from "@vitejs/plugin-react";
3-
import { tanstackRouter } from "@tanstack/router-plugin/vite";
4-
import { resolve } from "node:path";
5-
import { paraglideVitePlugin } from "@inlang/paraglide-js";
6-
import tailwindcss from "@tailwindcss/vite";
1+
import { defineConfig } from 'vite'
2+
import viteReact from '@vitejs/plugin-react'
3+
import { tanstackRouter } from '@tanstack/router-plugin/vite'
4+
import { resolve } from 'node:path'
5+
import { paraglideVitePlugin } from '@inlang/paraglide-js'
6+
import tailwindcss from '@tailwindcss/vite'
77

88
export default defineConfig({
99
plugins: [
1010
tailwindcss(),
1111
paraglideVitePlugin({
12-
project: "./project.inlang",
13-
outdir: "./src/paraglide",
14-
outputStructure: "message-modules",
15-
cookieName: "PARAGLIDE_LOCALE",
16-
strategy: ["url", "cookie", "preferredLanguage", "baseLocale"],
12+
project: './project.inlang',
13+
outdir: './src/paraglide',
14+
outputStructure: 'message-modules',
15+
cookieName: 'PARAGLIDE_LOCALE',
16+
strategy: ['url', 'cookie', 'preferredLanguage', 'baseLocale'],
1717
urlPatterns: [
1818
{
19-
pattern: "/",
19+
pattern: '/',
2020
localized: [
21-
["en", "/"],
22-
["de", "/de"],
21+
['en', '/'],
22+
['de', '/de'],
2323
],
2424
},
2525
{
26-
pattern: "/about",
26+
pattern: '/about',
2727
localized: [
28-
["en", "/about"],
29-
["de", "/de/ueber"],
28+
['en', '/about'],
29+
['de', '/de/ueber'],
3030
],
3131
},
3232
{
33-
pattern: "/:path(.*)?",
33+
pattern: '/:path(.*)?',
3434
localized: [
35-
["en", "/:path(.*)?"],
36-
["de", "/de/:path(.*)?"],
35+
['en', '/:path(.*)?'],
36+
['de', '/de/:path(.*)?'],
3737
],
3838
},
3939
],
@@ -43,7 +43,7 @@ export default defineConfig({
4343
],
4444
resolve: {
4545
alias: {
46-
"@": resolve(__dirname, "./src"),
46+
'@': resolve(__dirname, './src'),
4747
},
4848
},
49-
});
49+
})
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
{
2-
"recommendations": [
3-
"inlang.vs-code-extension"
4-
]
5-
}
2+
"recommendations": ["inlang.vs-code-extension"]
3+
}

0 commit comments

Comments
 (0)