Skip to content

Commit c36e682

Browse files
committed
translate 02-sveltekit/04-forms/01-the-form-element into Japanese
1 parent 4462e40 commit c36e682

File tree

1 file changed

+5
-5
lines changed
  • content/tutorial/02-sveltekit/04-forms/01-the-form-element

1 file changed

+5
-5
lines changed

content/tutorial/02-sveltekit/04-forms/01-the-form-element/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
title: The <form> element
33
---
44

5-
In the previous chapter, we saw how to get data from the server to the browser. Sometimes you need to send data in the opposite direction, and that's where `<form>` — the web platform's way of submitting data — comes in.
5+
前の章では、データをサーバーからブラウザに取得してくる方法を見てきました。時には、その逆方向にデータを送信する必要があります。そこで、web プラットフォームにおけるデータ送信方法である `<form>` の登場です。
66

7-
Let's build a todo app. We've already got an in-memory database set up in `src/lib/server/database.js`, and our `load` function in `src/routes/+page.server.js` uses the [`cookies`](https://kit.svelte.dev/docs/load#cookies-and-headers) API so that we can have a per-user todo list, but we need to add a `<form>` to create new todos:
7+
todo アプリを作ってみましょう。すでに `src/lib/server/database.js` にセットアップ済みのインメモリデータベースがあり、`src/routes/+page.server.js` `load` 関数で [`cookies`](https://kit.svelte.jp/docs/load#cookies-and-headers) API を使用しているためユーザーごとの todo リストを持つことができるようになっています。ここでは新しい todo を作成するための `<form>` を追加する必要があります。
88

99
```svelte
1010
/// file: src/routes/+page.svelte
@@ -20,7 +20,7 @@ Let's build a todo app. We've already got an in-memory database set up in `src/l
2020
{#each data.todos as todo}
2121
```
2222

23-
If we type something into the `<input>` and hit Enter, the browser makes a POST request (because of the `method="POST"` attribute) to the current page. But that results in an error, because we haven't created a server-side _action_ to handle the POST request. Let's do that now:
23+
追加した `<input>` になにか入力して Enter を押すと、ブラウザは現在のページに対する POST リクエストを作成します (`method="POST"` 属性があるため)。リクエストの結果がエラーになっているのは、その POST リクエストを処理するためのサーバーサイドの _action_ が作成されていないからです。では、それをやってみましょう。
2424

2525
```js
2626
/// file: src/routes/+page.server.js
@@ -38,6 +38,6 @@ export function load({ cookies }) {
3838
};+++
3939
```
4040

41-
When we hit Enter, the database is updated and the page reloads with the new data.
41+
Enter を押すと、データベースが更新され、新しいデータでページがリロードします。
4242

43-
Notice that we haven't had to write any `fetch` code or anything like that — data updates automatically. And because we're using a `<form>` element, this app would work even if JavaScript was disabled or unavailable.
43+
`fetch` コードなどを書く必要がなかったこと、データが自動的に更新されることにご注目ください。そして、`<form>` 要素を使用しているため、このアプリはたとえ JavaScript が無効または利用できない場合でも動作します。

0 commit comments

Comments
 (0)