Skip to content

Translate remaining untranslated documentation files to Japanese #1081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
eeb0a38
Add automatic translation of untranslated documents to Japanese using…
lemo-nade-room May 29, 2025
a1a9a7a
Fix mismatched heading IDs in Commands documentation
lemo-nade-room May 30, 2025
406686a
Update GET /hello middleware description to use “通過” instead of “訪問”
lemo-nade-room May 30, 2025
e96ea07
Remove incorrect markdown underscores in middleware insertion descrip…
lemo-nade-room May 30, 2025
fc2115b
Remove incorrect markdown underscores in middleware insertion descrip…
lemo-nade-room May 30, 2025
7cdd9db
Fix mismatched heading IDs in Server documentation
lemo-nade-room May 30, 2025
6faa8ea
Fix mismatched heading IDs in Testing documentation
lemo-nade-room May 30, 2025
9bc3acd
Update OpenTelemetry docs link to Japanese version
lemo-nade-room May 30, 2025
27446a3
Update Websockets docs link to Japanese version
lemo-nade-room May 30, 2025
961c886
Update Contributing docs link to Japanese version
lemo-nade-room May 30, 2025
b7a7454
Update Docker docs link to Japanese version
lemo-nade-room May 30, 2025
16021e2
Update head to use “接続” instead of “Android”
lemo-nade-room May 30, 2025
b828c9f
Fix mismatched heading IDs in Heroku documentation
lemo-nade-room May 30, 2025
3a5cb02
Update Nginx docs link to Japanese version
lemo-nade-room May 30, 2025
2305ddc
Fix mismatched heading IDs in Nginx documentation
lemo-nade-room May 30, 2025
42dae97
Update Nginx docs link to Japanese version
lemo-nade-room May 30, 2025
7eaebe1
Fix mismatched heading IDs in Supervisor documentation
lemo-nade-room May 30, 2025
3029c8e
Update head to use “論理削除” instead of “ソフトデリート”
lemo-nade-room May 30, 2025
f375920
Update head to use “Enum” instead of “列挙型”
lemo-nade-room May 30, 2025
1661adf
Update head to use “Parentドキュメント” instead of “親ドキュメント”
lemo-nade-room May 30, 2025
6af2df1
Update head to use “Join” instead of “結合”
lemo-nade-room May 30, 2025
40b992b
Fix mismatched heading IDs in Models documentation
lemo-nade-room May 30, 2025
a3501f9
Update head to use “Save, Create, Update, Delete, Find” instead of “保…
lemo-nade-room May 30, 2025
4e6c15f
Update head to use “論理削除” instead of “ソフト削除”
lemo-nade-room May 30, 2025
89abfe9
Update head to use “Update, Delete” instead of “更新, 削除”
lemo-nade-room May 30, 2025
151df13
Fix mismatched heading IDs in Transaction documentation
lemo-nade-room May 30, 2025
9dc3917
Fix mismatched heading IDs in Redis Overview documentation
lemo-nade-room May 30, 2025
053a46f
Update Crypto docs link to Japanese version
lemo-nade-room May 30, 2025
4c8ff6f
Fix mismatched heading IDs in Passwords documentation
lemo-nade-room May 30, 2025
359f89b
Remove incorrect markdown underscores in middleware insertion descrip…
lemo-nade-room May 30, 2025
12d9bd6
Fix mismatched heading IDs in Upgrading documentation
lemo-nade-room May 30, 2025
f2000c5
Fix mismatched heading IDs in Release Notes documentation
lemo-nade-room May 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions docs/advanced/apns.ja.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# APNS

VaporのApple Push Notification Service (APNS) APIを使用すると、Appleデバイスへのプッシュ通知の認証と送信が簡単になります。これは[APNSwift](https://github.com/swift-server-community/APNSwift)の上に構築されています。

## はじめに {#getting-started}

APNSの使用を開始する方法を見てみましょう。

### パッケージ {#package}

APNSを使用する最初のステップは、依存関係にパッケージを追加することです。

```swift
// swift-tools-version:5.8
import PackageDescription

let package = Package(
name: "my-app",
dependencies: [
// Other dependencies...
.package(url: "https://github.com/vapor/apns.git", from: "4.0.0"),
],
targets: [
.target(name: "App", dependencies: [
// Other dependencies...
.product(name: "VaporAPNS", package: "apns")
]),
// Other targets...
]
)
```

Xcode内で直接マニフェストを編集すると、ファイルが保存されたときに自動的に変更を検出し、新しい依存関係を取得します。それ以外の場合は、ターミナルから`swift package resolve`を実行して新しい依存関係を取得してください。

### 設定 {#configuration}

APNSモジュールは`Application`に新しいプロパティ`apns`を追加します。プッシュ通知を送信するには、認証情報を使用して`configuration`プロパティを設定する必要があります。

```swift
import APNS
import VaporAPNS
import APNSCore

// JWT認証を使用してAPNSを設定します。
let apnsConfig = APNSClientConfiguration(
authenticationMethod: .jwt(
privateKey: try .loadFrom(string: "<#key.p8 content#>"),
keyIdentifier: "<#key identifier#>",
teamIdentifier: "<#team identifier#>"
),
environment: .development
)
app.apns.containers.use(
apnsConfig,
eventLoopGroupProvider: .shared(app.eventLoopGroup),
responseDecoder: JSONDecoder(),
requestEncoder: JSONEncoder(),
as: .default
)
```

プレースホルダーを認証情報で置き換えてください。上記の例は、Appleの開発者ポータルから取得した`.p8`キーを使用した[JWTベースの認証](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_token-based_connection_to_apns)を示しています。証明書を使用した[TLSベースの認証](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_certificate-based_connection_to_apns)の場合は、`.tls`認証方法を使用してください:

```swift
authenticationMethod: .tls(
privateKeyPath: <#path to private key#>,
pemPath: <#path to pem file#>,
pemPassword: <#optional pem password#>
)
```

### 送信 {#send}

APNSが設定されたら、`Application`または`Request`の`apns.send`メソッドを使用してプッシュ通知を送信できます。

```swift
// カスタムCodableペイロード
struct Payload: Codable {
let acme1: String
let acme2: Int
}
// プッシュ通知アラートを作成
let dt = "70075697aa918ebddd64efb165f5b9cb92ce095f1c4c76d995b384c623a258bb"
let payload = Payload(acme1: "hey", acme2: 2)
let alert = APNSAlertNotification(
alert: .init(
title: .raw("Hello"),
subtitle: .raw("This is a test from vapor/apns")
),
expiration: .immediately,
priority: .immediately,
topic: "<#my topic#>",
payload: payload
)
// 通知を送信
try! await req.apns.client.sendAlertNotification(
alert,
deviceToken: dt,
deadline: .distantFuture
)
```

ルートハンドラー内にいる場合は、`req.apns`を使用してください。

```swift
// プッシュ通知を送信します。
app.get("test-push") { req async throws -> HTTPStatus in
try await req.apns.client.send(...)
return .ok
}
```

最初のパラメータはプッシュ通知アラートを受け取り、2番目のパラメータはターゲットデバイストークンです。

## アラート {#alert}

`APNSAlertNotification`は、送信するプッシュ通知アラートの実際のメタデータです。各プロパティの詳細については[こちら](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/PayloadKeyReference.html)で提供されています。これらはAppleのドキュメントに記載されている1対1の命名規則に従っています。

```swift
let alert = APNSAlertNotification(
alert: .init(
title: .raw("Hello"),
subtitle: .raw("This is a test from vapor/apns")
),
expiration: .immediately,
priority: .immediately,
topic: "<#my topic#>",
payload: payload
)
```

このタイプは`send`メソッドに直接渡すことができます。

### カスタム通知データ {#custom-notification-data}

Appleは、各通知にカスタムペイロードデータを追加する機能をエンジニアに提供しています。これを容易にするために、すべての`send` APIのペイロードパラメータに`Codable`準拠を受け入れています。

```swift
// カスタムCodableペイロード
struct Payload: Codable {
let acme1: String
let acme2: Int
}
```

## 詳細情報 {#more-information}

利用可能なメソッドの詳細については、[APNSwiftのREADME](https://github.com/swift-server-community/APNSwift)を参照してください。
129 changes: 129 additions & 0 deletions docs/advanced/commands.ja.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# コマンド {#commands}

VaporのCommand APIを使用すると、カスタムコマンドライン関数を構築し、ターミナルと対話できます。これは、`serve`、`routes`、`migrate`などのVaporのデフォルトコマンドが構築されている基盤です。

## デフォルトコマンド {#default-commands}

`--help`オプションを使用して、Vaporのデフォルトコマンドについて詳しく学ぶことができます。

```sh
swift run App --help
```

特定のコマンドに`--help`を使用すると、そのコマンドが受け入れる引数とオプションを確認できます。

```sh
swift run App serve --help
```

### Xcode

Xcodeでコマンドを実行するには、`App`スキームに引数を追加します。これを行うには、次の手順に従います:

- `App`スキームを選択(再生/停止ボタンの右側)
- 「Edit Scheme」をクリック
- 「App」プロダクトを選択
- 「Arguments」タブを選択
- 「Arguments Passed On Launch」にコマンド名を追加(例:`serve`)

## カスタムコマンド {#custom-commands}

`AsyncCommand`に準拠する型を作成することで、独自のコマンドを作成できます。

```swift
import Vapor

struct HelloCommand: AsyncCommand {
...
}
```

カスタムコマンドを`app.asyncCommands`に追加すると、`swift run`経由で利用可能になります。

```swift
app.asyncCommands.use(HelloCommand(), as: "hello")
```

`AsyncCommand`に準拠するには、`run`メソッドを実装する必要があります。これには`Signature`の宣言が必要です。また、デフォルトのヘルプテキストも提供する必要があります。

```swift
import Vapor

struct HelloCommand: AsyncCommand {
struct Signature: CommandSignature { }

var help: String {
"Says hello"
}

func run(using context: CommandContext, signature: Signature) async throws {
context.console.print("Hello, world!")
}
}
```

このシンプルなコマンドの例には引数やオプションがないため、シグネチャは空のままにします。

提供されたコンテキストを介して現在のコンソールにアクセスできます。コンソールには、ユーザー入力のプロンプト、出力のフォーマットなど、多くの便利なメソッドがあります。

```swift
let name = context.console.ask("What is your \("name", color: .blue)?")
context.console.print("Hello, \(name) 👋")
```

次のコマンドを実行してコマンドをテストします:

```sh
swift run App hello
```

### Cowsay

`@Argument`と`@Option`の使用例として、有名な[`cowsay`](https://en.wikipedia.org/wiki/Cowsay)コマンドの再現を見てみましょう。

```swift
import Vapor

struct Cowsay: AsyncCommand {
struct Signature: CommandSignature {
@Argument(name: "message")
var message: String

@Option(name: "eyes", short: "e")
var eyes: String?

@Option(name: "tongue", short: "t")
var tongue: String?
}

var help: String {
"Generates ASCII picture of a cow with a message."
}

func run(using context: CommandContext, signature: Signature) async throws {
let eyes = signature.eyes ?? "oo"
let tongue = signature.tongue ?? " "
let cow = #"""
< $M >
\ ^__^
\ ($E)\_______
(__)\ )\/\
$T ||----w |
|| ||
"""#.replacingOccurrences(of: "$M", with: signature.message)
.replacingOccurrences(of: "$E", with: eyes)
.replacingOccurrences(of: "$T", with: tongue)
context.console.print(cow)
}
}
```

これをアプリケーションに追加して実行してみてください。

```swift
app.asyncCommands.use(Cowsay(), as: "cowsay")
```

```sh
swift run App cowsay sup --eyes ^^ --tongue "U "
```
97 changes: 97 additions & 0 deletions docs/advanced/files.ja.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# ファイル {#files}

Vaporは、ルートハンドラ内でファイルを非同期に読み書きするためのシンプルなAPIを提供しています。このAPIは、NIOの[`NonBlockingFileIO`](https://swiftpackageindex.com/apple/swift-nio/main/documentation/nioposix/nonblockingfileio)型の上に構築されています。

## 読み取り {#read}

ファイルを読み取るための主要なメソッドは、ディスクから読み取られたチャンクをコールバックハンドラに配信します。読み取るファイルはパスで指定します。相対パスは、プロセスの現在の作業ディレクトリを参照します。

```swift
// ディスクからファイルを非同期に読み取ります。
let readComplete: EventLoopFuture<Void> = req.fileio.readFile(at: "/path/to/file") { chunk in
print(chunk) // ByteBuffer
}

// または

try await req.fileio.readFile(at: "/path/to/file") { chunk in
print(chunk) // ByteBuffer
}
// 読み取り完了
```

`EventLoopFuture`を使用している場合、返されたfutureは読み取りが完了したか、エラーが発生したときにシグナルを送ります。`async`/`await`を使用している場合、`await`が返ると読み取りが完了しています。エラーが発生した場合は、エラーをスローします。

### ストリーム {#stream}

`streamFile`メソッドは、ストリーミングファイルを`Response`に変換します。このメソッドは、`ETag`や`Content-Type`などの適切なヘッダーを自動的に設定します。

```swift
// ファイルを非同期にHTTPレスポンスとしてストリームします。
req.fileio.streamFile(at: "/path/to/file").map { res in
print(res) // Response
}

// または

let res = req.fileio.streamFile(at: "/path/to/file")
print(res)

```

結果は、ルートハンドラから直接返すことができます。

### 収集 {#collect}

`collectFile`メソッドは、指定されたファイルをバッファに読み込みます。

```swift
// ファイルをバッファに読み込みます。
req.fileio.collectFile(at: "/path/to/file").map { buffer in
print(buffer) // ByteBuffer
}

// または

let buffer = req.fileio.collectFile(at: "/path/to/file")
print(buffer)
```

!!! warning
このメソッドは、ファイル全体を一度にメモリに読み込む必要があります。メモリ使用量を制限するには、チャンクまたはストリーミング読み取りを使用してください。

## 書き込み {#write}

`writeFile`メソッドは、バッファをファイルに書き込むことをサポートしています。

```swift
// バッファをファイルに書き込みます。
req.fileio.writeFile(ByteBuffer(string: "Hello, world"), at: "/path/to/file")
```

返されたfutureは、書き込みが完了したか、エラーが発生したときにシグナルを送ります。

## ミドルウェア {#middleware}

プロジェクトの_Public_フォルダから自動的にファイルを提供する方法の詳細については、[ミドルウェア &rarr; FileMiddleware](middleware.md#file-middleware)を参照してください。

## 高度な使い方 {#advanced}

VaporのAPIがサポートしていないケースでは、NIOの`NonBlockingFileIO`型を直接使用できます。

```swift
// メインスレッド。
let fileHandle = try await app.fileio.openFile(
path: "/path/to/file",
eventLoop: app.eventLoopGroup.next()
).get()
print(fileHandle)

// ルートハンドラ内。
let fileHandle = try await req.application.fileio.openFile(
path: "/path/to/file",
eventLoop: req.eventLoop)
print(fileHandle)
```

詳細については、SwiftNIOの[APIリファレンス](https://swiftpackageindex.com/apple/swift-nio/main/documentation/nioposix/nonblockingfileio)をご覧ください。
Loading