Skip to content

Commit 202f228

Browse files
committed
translate 04-advanced-sveltekit/05-environment-variables into Japanese
1 parent d4bf917 commit 202f228

File tree

4 files changed

+22
-22
lines changed
  • content/tutorial/04-advanced-sveltekit/05-environment-variables

4 files changed

+22
-22
lines changed

content/tutorial/04-advanced-sveltekit/05-environment-variables/01-env-static-private/README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
title: $env/static/private
33
---
44

5-
Environment variables — like API keys and database credentials — can be added to a `.env` file, and they will be made available to your application.
5+
API キーやデータベースの認証情報などの環境変数は `.env` ファイルに追加することでき、アプリケーションから使えるようになります。
66

7-
> You can also use `.env.local` or `.env.[mode]` filessee the [Vite documentation](https://vitejs.dev/guide/env-and-mode.html#env-files) for more information). Make sure you add any files containing sensitive information to your `.gitignore` file!
7+
> また、`.env.local` ファイルや `.env.[mode]` ファイルも使えます詳細は [Vite のドキュメント](https://vitejs.dev/guide/env-and-mode.html#env-files) をご覧ください。機密情報を含むファイルは必ず `.gitignore` ファイルに追加してください!
88
9-
In this exercise, we want to allow the user to enter the website if they know the correct passphrase, using an environment variable.
9+
この練習問題では、環境変数を使って、正しいパスフレーズを知っているユーザーのみ web サイトを見ることができるようにしたいと思います。
1010

11-
First, in `.env`, add a new environment variable:
11+
まず、`.env` に新しい環境変数を追加します。
1212

1313
```env
1414
/// file: .env
1515
PASSPHRASE=+++"open sesame"+++
1616
```
1717

18-
Open `src/routes/+page.server.js`. Import `PASSPHRASE` from `$env/static/private` and use it inside the [form action](/tutorial/the-form-element):
18+
`src/routes/+page.server.js` を開いてください。`$env/static/private` から `PASSPHRASE` をインポートし、[form action](/tutorial/the-form-element) の中でそれを使用してください。
1919

2020
```js
2121
/// file: src/routes/+page.server.js
@@ -47,15 +47,15 @@ export const actions = {
4747
};
4848
```
4949

50-
The website is now accessible to anyone who knows the correct passphrase.
50+
正しいパスフレーズを知っている人が、web サイトにアクセスできるようになりました。
5151

52-
> Environment variables in `process.env` are also available via `$env/static/private`.
52+
> `process.env` にある環境変数も `$env/static/private` 経由で使うことができます。
5353
5454
## Keeping secrets
5555

56-
It's important that sensitive data doesn't accidentally end up being sent to the browser, where it could easily be stolen by hackers and scoundrels.
56+
機密データが誤ってブラウザに送信されるとハッカーや悪者に簡単に盗まれてしまうので、そうならないようにすることが重要です。
5757

58-
SvelteKit makes it easy to prevent this from happening. Notice what happens if we try to import `PASSPHRASE` into `src/routes/+page.svelte`:
58+
SvelteKit では、これを簡単に防ぐことができます。もし `PASSPHRASE` `src/routes/+page.svelte` にインポートしようとしたらどうなるか確認してみましょう。
5959

6060
```svelte
6161
/// file: src/routes/+page.svelte
@@ -65,27 +65,27 @@ SvelteKit makes it easy to prevent this from happening. Notice what happens if w
6565
</script>
6666
```
6767

68-
An error overlay pops up, telling us that `$env/static/private` cannot be imported into client-side code. It can only be imported into server modules:
68+
エラーオーバーレイが表示され、`$env/static/private` はクライアントサイドコードにインポートできないことを教えてくれます。これはサーバーモジュールにのみインポートすることができます。
6969

7070
- `+page.server.js`
7171
- `+layout.server.js`
7272
- `+server.js`
73-
- any modules ending with `.server.js`
74-
- any modules inside `src/lib/server`
73+
- `.server.js` で終わるモジュール
74+
- `src/lib/server` に置いてあるモジュール
7575

76-
In turn, these modules can only be imported by _other_ server modules.
76+
同様に、これらのモジュールは他のサーバーモジュールにのみインポートすることができます。
7777

7878
## Static vs dynamic
7979

80-
The `static` in `$env/static/private` indicates that these values are known at build time, and can be _statically replaced_. This enables useful optimisations:
80+
`$env/static/private` にある `static` とは、これらの値がビルド時に解決され、 _静的に置き換えられる_ ということを示しています。これによって最適化が可能になります。
8181

8282
```js
8383
import { FEATURE_FLAG_X } from '$env/static/private';
8484

8585
if (FEATURE_FLAG_X === 'enabled') {
86-
// code in here will be removed from the build output
87-
// if FEATURE_FLAG_X is not enabled
86+
// FEATURE_FLAG_X が enabled でない場合、
87+
// ここにあるコードはビルド出力から削除されます
8888
}
8989
```
9090

91-
In some cases you might need to refer to environment variables that are _dynamic_ — in other words, not known until we run the app. We'll cover this case in the next exercise.
91+
場合によっては、 _動的_ な環境変数 — 言い換えると、アプリの実行時までわからない環境変数を参照する必要があるかもしれません。これについては、次の練習問題で説明します。

content/tutorial/04-advanced-sveltekit/05-environment-variables/02-env-dynamic-private/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: $env/dynamic/private
33
---
44

5-
If you need to read the values of environment variables when the app runs, as opposed to when the app is built, you can use `$env/dynamic/private` instead of `$env/static/private`:
5+
アプリのビルド時ではなく、アプリの実行時に環境変数の値を読む必要がある場合、`$env/static/private` の代わりに `$env/dynamic/private` を使用することができます。
66

77
```js
88
/// file: src/routes/+page.server.js

content/tutorial/04-advanced-sveltekit/05-environment-variables/03-env-static-public/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
title: $env/static/public
33
---
44

5-
Some environment variables _can_ be safely exposed to the browser. These are distinguished from private environment variables with a `PUBLIC_` prefix.
5+
ブラウザに公開しても安全な環境変数もあります。これらは `PUBLIC_` プリフィクスを付けることで、プライベートな環境変数と区別します。
66

7-
Add values to the two public environment variables in `.env`:
7+
`.env` にある2つのパブリックな環境変数に値を追加します。
88

99
```env
1010
PUBLIC_THEME_BACKGROUND=+++"steelblue"+++
1111
PUBLIC_THEME_FOREGROUND=+++"bisque"+++
1212
```
1313

14-
Then, import them into `src/routes/+page.svelte`:
14+
そして、これらを `src/routes/+page.svelte` にインポートします。
1515

1616
```svelte
1717
/// file: src/routes/+page.svelte

content/tutorial/04-advanced-sveltekit/05-environment-variables/04-env-dynamic-public/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: $env/dynamic/public
33
---
44

5-
As with [private environment variables](/tutorial/env-static-private), it's preferable to use static values if possible, but if necessary we can use dynamic values instead:
5+
[プライベートな環境変数](/tutorial/env-static-private) と同様、可能なら静的な値を使用することが望ましいですが、必要であれば代わりに動的な値を使用することができます。
66

77
```svelte
88
<script>

0 commit comments

Comments
 (0)