Skip to content

Commit 46460bd

Browse files
committed
translate 04-advanced-sveltekit/03-advanced-routing into Japanese
1 parent 84b34cf commit 46460bd

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

content/tutorial/04-advanced-sveltekit/03-advanced-routing/01-optional-params/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
title: Optional parameters
33
---
44

5-
In the first chapter on [routing](/tutorial/pages), we learned how to create routes with [dynamic parameters](/tutorial/params).
5+
[ルーティング(Routing)](/tutorial/pages) の最初の章で、[動的なパラメータ](/tutorial/params)付きのルート(routes)を作成する方法について学習しました。
66

7-
Sometimes it's helpful to make a parameter optional. A classic example is when you use the pathname to determine the locale `/fr/...`, `/de/...` and so on — but you also want to have a default locale.
7+
パラメータをオプショナルにできたら便利なときがあるでしょう。その代表的な例は、ロケールを決めるのにパス名を使用する場合です `/fr/...``/de/...` などなど — このとき、デフォルトのロケールも持ちたいはずです。
88

9-
To do that, we use double brackets. Rename the `[lang]` directory to `[[lang]]`.
9+
そうするには、二重括弧を使用します。`[lang]` ディレクトリを `[[lang]]` にリネームしましょう。
1010

11-
The app now fails to build, because `src/routes/+page.svelte` and `src/routes/[[lang]]/+page.svelte` would both match `/`. Delete `src/routes/+page.svelte`. (You may need to reload the app to recover from the error page).
11+
今は `src/routes/+page.svelte` `src/routes/[[lang]]/+page.svelte` がどちらも `/` にマッチするため、アプリがビルドに失敗します。`src/routes/+page.svelte` を削除してください (エラーページから復帰するには、アプリをリロードする必要があるかもしれません)。
1212

13-
Lastly, edit `src/routes/[[lang]]/+page.server.js` to specify the default locale:
13+
最後に、`src/routes/[[lang]]/+page.server.js` を編集してデフォルトロケールを指定してください。
1414

1515
```js
1616
/// file: src/routes/[[lang]]/+page.server.js

content/tutorial/04-advanced-sveltekit/03-advanced-routing/02-rest-params/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
title: Rest parameters
33
---
44

5-
To match an unknown number of path segments, use a `[...rest]` parameter, so named for its resemblance to [rest parameters in JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).
5+
未知の数のパスセグメントにマッチさせるには、`[...rest]` パラメータを使用します。これは、 [JavaScript の残余引数(rest parameters)](https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Functions/rest_parameters) に似ているため、この名前が付けられました。
66

7-
Rename `src/routes/[path]` to `src/routes/[...path]`. The route now matches any path.
7+
`src/routes/[path]` `src/routes/[...path]` にリネームしましょう。このルート(route)はどんなパスにもマッチします。
88

9-
> Other, more specific routes will be tested first, making rest parameters useful as 'catch-all' routes. For example, if you needed a custom 404 page for pages inside `/categories/...`, you could add these files:
9+
> 他の、より詳細・明確(specific)なルート(routes)が最初にテストされるため、rest パラメータは 'catch-all' ルート(routes)として便利です。例えば、`/categories/...` の中のページ用にカスタムの 404 ページを必要とする場合は、以下のファイルを追加することができます。
1010
>
1111
> ```diff
1212
> src/routes/
@@ -19,4 +19,4 @@ Rename `src/routes/[path]` to `src/routes/[...path]`. The route now matches any
1919
> +│ │ └ +page.server.js
2020
> ```
2121
>
22-
> Inside the `+page.server.js` file, `throw error(404)` inside `load`.
22+
> `+page.server.js` ファイルにて、`load` の内側で `throw error(404)` のようにエラーをスローします。

content/tutorial/04-advanced-sveltekit/03-advanced-routing/03-param-matchers/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ title: Param matchers
33
path: /colors/ff3e00
44
---
55

6-
To prevent the router from matching on invalid input, you can specify a _matcher_. For example, you might want a route like `/colors/[value]` to match hex values like `/colors/ff3e00` but not named colors like `/colors/octarine` or any other arbitrary input.
6+
ルーターが無効な入力にマッチするのを防ぐために、 _matcher_ を指定することができます。例えば、`/colors/[value]` のようなルート(route)を、`/colors/ff3e00` のような16進数の値(hex value)にマッチさせたいけれど、`/colors/octarine` のような色の名前やその他の任意の入力にはマッチさせたくないことがあるでしょう。
77

8-
First, create a new file called `src/params/hex.js` and export a `match` function from it:
8+
まず、`src/params/hex.js` という新しいファイルを作成し、そこから `match` 関数をエクスポートしてください。
99

1010
```js
1111
/// file: src/params/hex.js
@@ -14,8 +14,8 @@ export function match(value) {
1414
}
1515
```
1616

17-
Then, to use the new matcher, rename `src/routes/colors/[color]` to `src/routes/colors/[color=hex]`.
17+
それから、その新しい matcher を使うために、`src/routes/colors/[color]` `src/routes/colors/[color=hex]` にリネームしてください。
1818

19-
Now, whenever someone navigates to that route, SvelteKit will verify that `color` is a valid `hex` value. If not, SvelteKit will try to match other routes, before eventually returning a 404.
19+
これで、誰かがこのルート(route)に移動してきたときはいつでも、SvelteKit `color` が有効な `hex` value か検証します。違った場合、SvelteKit は、他のルート(routes)にマッチするか試行し、どれにもマッチしない場合は最終的に 404 を返します。
2020

21-
> Matchers run both on the server and in the browser.
21+
> Matcher はサーバーとブラウザの両方で動作します。

content/tutorial/04-advanced-sveltekit/03-advanced-routing/04-route-groups/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
title: Route groups
33
---
44

5-
As we saw in the [routing introduction](/tutorial/layouts), layouts are a way to share UI and data loading logic between different routes.
5+
[ルーティング(Routing)のイントロダクション](/tutorial/layouts)で見たように、レイアウトによって UI とデータをロードするロジックを異なるルート(routes)間で共有することができます。
66

7-
Sometimes it's useful to use layouts without affecting the route — for example, you might need your `/app` and `/account` routes to be behind authentication, while your `/about` page is open to the world. We can do this with a _route group_, which is a directory in parentheses.
7+
ルート(route)に影響することなく、レイアウトを使うことができたら便利なときがあるでしょう例えば、`/app` ルートと `/account` ルートは認証の背後に置く必要があり、`/about` ページは世界に公開する、ということがあるかもしれません。これを行うには、 _ルートグループ(route group)_ を使います。これは、丸括弧でくくられたディレクトリです。
88

9-
Create an `(authed)` group by renaming `account` to `(authed)/account` then renaming `app` to `(authed)/app`.
9+
`account` `(authed)/account` にリネームして `(authed)` グループを作成し、それから `app` `(authed)/app` にリネームします。
1010

11-
Now we can control access to these routes by creating `src/routes/(authed)/+layout.server.js`:
11+
`src/routes/(authed)/+layout.server.js` を作成することで、これらのルート(routes)のアクセスをコントロールすることができます。
1212

1313
```js
1414
/// file: src/routes/(authed)/+layout.server.js
@@ -21,9 +21,9 @@ export function load({ cookies, url }) {
2121
}
2222
```
2323

24-
If you try to visit these pages, you'll be redirected to the `/login` route, which has a form action in `src/routes/login/+page.server.js` that sets the `logged_in` cookie.
24+
これらのページにアクセスしようとすると、`/login` ルート(route)にリダイレクトされます。このルートには、`src/routes/login/+page.server.js` に、`logged_in` cookie をセットする form action があります。
2525

26-
We can also add some UI to these two routes by adding a `src/routes/(authed)/+layout.svelte` file:
26+
また、`src/routes/(authed)/+layout.svelte` ファイルを追加することで、これら2つのルートに UI を追加することができます。
2727

2828
```svelte
2929
/// file: src/routes/(authed)/+layout.svelte

content/tutorial/04-advanced-sveltekit/03-advanced-routing/05-breaking-out-of-layouts/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
title: Breaking out of layouts
33
---
44

5-
Ordinarily, a page inherits every layout above it, meaning that `src/routes/a/b/c/+page.svelte` inherits four layouts:
5+
通常、ページはその上にある全てのレイアウトを継承しています。つまり、`src/routes/a/b/c/+page.svelte` は4つのレイアウトを継承しています。
66

77
- `src/routes/+layout.svelte`
88
- `src/routes/a/+layout.svelte`
99
- `src/routes/a/b/+layout.svelte`
1010
- `src/routes/a/b/c/+layout.svelte`
1111

12-
Occasionally, it's useful to break out of the current layout hierarchy. We can do that by adding the `@` sign followed by the name of the parent segment to 'reset' to — for example `[email protected]` would put `/a/b/c` inside `src/routes/a/b/+layout.svelte`, while `[email protected]` would put it inside `src/routes/a/+layout.svelte`.
12+
たまに、現在のレイアウト階層から抜け出せると便利なときもあります。`@` 記号の後に'リセット'する親セグメントの名前を追加することで、これを実現することができます — 例えば、`/a/b/c` `[email protected]` にすると `src/routes/a/b/+layout.svelte` が適用され、`[email protected]` の場合は `src/routes/a/+layout.svelte` が適用されます。
1313

14-
Let's reset it all the way to the root layout, by renaming it to `[email protected]`.
14+
`[email protected]` にリネームして、一気に最上位(root)のレイアウトまでリセットしてみましょう。
1515

16-
> The root layout applies to every page of your app, you cannot break out of it.
16+
> 最上位(root)のレイアウトはアプリの全てのページに適用され、そこから抜け出すことはできません。

0 commit comments

Comments
 (0)