Skip to content
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

プリント文の翻訳 part 2 #342

Merged
merged 23 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c41c55a
print Translation
SatoTakeshiX Aug 7, 2022
f5a4f52
finish collection type
SatoTakeshiX Aug 8, 2022
73e2f67
print transition
SatoTakeshiX Aug 8, 2022
86943fc
print transition
SatoTakeshiX Aug 9, 2022
555e374
print transition
SatoTakeshiX Aug 9, 2022
1a5ebdd
Merge commit 'c03909c94c0f9430a6873756aff2065e8e0e5378' into translat…
SatoTakeshiX Aug 12, 2022
cb962ad
translation print sentence to deinitialization
SatoTakeshiX Aug 12, 2022
f7789ac
translate print sentence
SatoTakeshiX Aug 12, 2022
8a7a595
process enumerations
SatoTakeshiX Aug 12, 2022
32b9e5b
translate print sentence in initialization
SatoTakeshiX Aug 13, 2022
aa060de
translate print sentence for error and extensions
SatoTakeshiX Aug 13, 2022
5c975a8
translate print sentence for functions
SatoTakeshiX Aug 13, 2022
48cdf87
translate print sentence for inheritance
SatoTakeshiX Aug 13, 2022
434a723
translate print sentence for generics
SatoTakeshiX Aug 13, 2022
11be422
Merge commit 'b7abfc6a19adc5284bdd87e442bd944d6c488bc1' into translat…
SatoTakeshiX Aug 13, 2022
7b9de97
self review
SatoTakeshiX Aug 13, 2022
0cf86c4
adding 2 space after date
SatoTakeshiX Aug 13, 2022
6b52a7a
apply the feedbacks
SatoTakeshiX Aug 14, 2022
ed64796
apply stzn san feedbacks
SatoTakeshiX Aug 14, 2022
50bb671
apply stzn san feedback
SatoTakeshiX Aug 14, 2022
40ba5b1
Update language-guide/control-flow.md
SatoTakeshiX Aug 17, 2022
70cf15f
Update language-guide/control-flow.md
SatoTakeshiX Aug 17, 2022
1e3dc79
apply t-ae san feedback
SatoTakeshiX Aug 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion language-guide/access-control.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# アクセスコントロール\(Access Control\)

最終更新日: 2022/8/5
最終更新日: 2022/8/9
原文: https://docs.swift.org/swift-book/LanguageGuide/AccessControl.html

アクセス制御は、他のソースファイルやモジュールのコードから一部のコードへのアクセスを制限します。この機能を使用すると、コードの実装の詳細を隠し、そのコードにアクセスして使用するために望ましいインターフェイスを指定できます。
Expand Down
2 changes: 1 addition & 1 deletion language-guide/advanced-operators.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 高度な演算子\(Advanced Operators\)

最終更新日: 2022/8/10
最終更新日: 2022/8/12
原文: https://docs.swift.org/swift-book/LanguageGuide/AdvancedOperators.html

[Basic Operators\(基本演算子\)](basic-operators.md)で説明されている演算子に加えて、Swift は、より複雑な値操作を実行するいくつかの高度な演算子を提供します。これらには、C 言語および Objective-C でおなじみの全てのビット演算子およびビットシフト演算子が含まれます。
Expand Down
2 changes: 1 addition & 1 deletion language-guide/automatic-reference-counting.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 自動参照カウント ARC\(Automatic Reference Counting\)

最終更新日: 2021/6/30
最終更新日: 2022/8/7
原文: https://docs.swift.org/swift-book/LanguageGuide/AutomaticReferenceCounting.html

Swift は自動参照カウント\(以下 _ARC_ \)を使用して、アプリのメモリ使用状況を追跡および管理します。ほとんどの場合、これはメモリ管理が Swift によって「ただ行われている」ことを意味し、メモリ管理について自身で考える必要はありません。ARC は、クラスインスタンスが不要になったときに、クラスインスタンスによって使用されていたメモリを自動的に解放します。
Expand Down
2 changes: 1 addition & 1 deletion language-guide/basic-operators.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 基本演算子\(Basic Operators\)

最終更新日: 2021/6/27
最終更新日: 2022/8/12
原文: https://docs.swift.org/swift-book/LanguageGuide/BasicOperators.html

_演算子_は、値のチェックや変更、合成するために使われる特殊な記号や用語です。例えば、加算演算子\(`+`\)は `let i = 1 + 2` のように 2 つの数値を足します。論理 AND 演算子\(`&&`\)は、`if enteredDoorCode && passedRetinaScan` のように 2 つのブール値を組み合わせます。
Expand Down
26 changes: 13 additions & 13 deletions language-guide/closures.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# クロージャ\(Closures\)

最終更新日: 2022/4/26
最終更新日: 2022/8/13
原文: https://docs.swift.org/swift-book/LanguageGuide/Closures.html

_クロージャ_は、コード内で受け渡して使用できる、ある機能の独立したブロックです。Swift のクロージャは、C 言語や Objective-C のブロック、他のプログラミング言語のラムダに似ています。
Expand Down Expand Up @@ -230,7 +230,7 @@ func loadPicture(from server: Server, completion: (Picture) -> Void, onFailure:
loadPicture(from: someServer) { picture in
someView.currentPicture = picture
} onFailure: {
print("Couldn't download the next picture.")
print("画像がダウンロードできませんでした。")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("画像がダウンロードできませんでした。")
print("画像をダウンロードできませんでした。")

}
```

Expand Down Expand Up @@ -414,8 +414,8 @@ let customerProvider = { customersInLine.remove(at: 0) }
print(customersInLine.count)
// 5

print("Now serving \(customerProvider())!")
// Now serving Chris!
print("ただ今 \(customerProvider()) を接客中!")
// ただ今 Chris を接客中!
print(customersInLine.count)
// 4
```
Expand All @@ -427,21 +427,21 @@ print(customersInLine.count)
```swift
// customersInLine は ["Alex", "Ewa", "Barry", "Daniella"]
func serve(customer customerProvider: () -> String) {
print("Now serving \(customerProvider())!")
print("ただ今 \(customerProvider()) を接客中!")
}
serve(customer: { customersInLine.remove(at: 0) } )
// Now serving Alex!
// ただ今 Alex を接客中!
```

上記のリストの `serve(customer:)` 関数は、顧客の名前を返す明示的なクロージャを受け取ります。下記のバージョンの `serve(customer:)` は同じ操作を実行しますが、明示的なクロージャを取得する代わりに、パラメータの型を `@autoclosure` 属性でマークすることによって自動クロージャを取得します。これで、クロージャの代わりに `String` 引数を受け取ったかのように関数を呼び出すことができます。`customerProvider` パラメータの型は `@autoclosure` 属性でマークされているため、引数は自動的にクロージャに変換されます。

```swift
// customersInLine は ["Ewa", "Barry", "Daniella"]
func serve(customer customerProvider: @autoclosure () -> String) {
print("Now serving \(customerProvider())!")
print("ただ今 \(customerProvider()) を接客中!")
}
serve(customer: customersInLine.remove(at: 0))
// Now serving Ewa!
// ただ今 Ewa を接客中!
```

> NOTE
Expand All @@ -458,13 +458,13 @@ func collectCustomerProviders(_ customerProvider: @autoclosure @escaping () -> S
collectCustomerProviders(customersInLine.remove(at: 0))
collectCustomerProviders(customersInLine.remove(at: 0))

print("Collected \(customerProviders.count) closures.")
// Collected 2 closures.
print("集められた \(customerProviders.count) 個のクロージャー。")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

集められたという表現がややわかりづらいかなあと思いました。配列には今何個のprovider があります的なニュアンスを上手く表現したいですね。

Suggested change
print("集められた \(customerProviders.count) 個のクロージャー。")
print("\(customerProviders.count) 個のクロージャーが保持されています。")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

わかりやすくなったと思います。 保持されています良いと思います

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

// 集められた 2 個のクロージャー。
for customerProvider in customerProviders {
print("Now serving \(customerProvider())!")
print("ただ今 \(customerProvider()) を接客中!")
}
// Now serving Barry!
// Now serving Daniella!
// ただ今 Barry を接客中!
// ただ今 Daniella を接客中!
```

上記のコードでは、`customerProvider` 引数として渡されたクロージャを呼び出す代わりに、`collectCustomerProviders(_:)` 関数がクロージャを `customerProviders` 配列に追加します。配列は関数のスコープ外で宣言されています。つまり、配列のクロージャは関数が戻った後に実行される場合があります。その結果、`customerProvider` 引数の値は、関数のスコープをエスケープできるようにする必要があります。
Expand Down
96 changes: 48 additions & 48 deletions language-guide/collection-types.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# コレクション型\(Collection Types\)

最終更新日: 2021/6/27
最終更新日: 2022/8/13
原文: https://docs.swift.org/swift-book/LanguageGuide/CollectionTypes.html

Swift は、配列、セット、辞書と呼ばれる 3 つの基本的な_コレクション型_を提供しています。配列は順序が決まったコレクションです。セットは値の重複と順序のないコレクションです。辞書はキーとバリューに関連性を持たせた順序のないコレクションです。
Expand Down Expand Up @@ -36,8 +36,8 @@ Swift の配列の型は全体で `Array<Element>` と書きます。`Element`

```swift
var someInts = [Int]()
print("someInts is of type [Int] with \(someInts.count) items.")
// someInts is of type [Int] with 0 items.
print("someInts \(someInts.count) 個の要素を持つ [Int] 型です。")
// someInts は 0 個の要素を持つ [Int] 型です。
```

`someInts` 変数の型は、イニシャライザから `[Int]` と推論されます。
Expand Down Expand Up @@ -107,19 +107,19 @@ var shoppingList = ["Eggs", "Milk"]
配列のアイテムの数を調べるために、読み取り専用の `count` プロパティをチェックします。

```swift
print("The shopping list contains \(shoppingList.count) items.")
// The shopping list contains 2 items.
print("ショッピングリストには \(shoppingList.count) 個のアイテムがあります。")
// ショッピングリストには 2 個のアイテムがあります。
```

`Bool` 型の `isEmpty` プロパティは、`count` プロパティが `0` かどうかをチェックする簡略記法です。

```swift
if shoppingList.isEmpty {
print("The shopping list is empty.")
print("ショッピングリストは空です。")
} else {
print("The shopping list isn't empty.")
print("ショッピングリストは空ではありません。")
}
// The shopping list isn't empty.
// ショッピングリストは空ではありません。
```

`append(_:)` メソッドを使用して、配列の末尾に新しいアイテムを追加することができます。
Expand Down Expand Up @@ -221,13 +221,13 @@ for item in shoppingList {

```swift
for (index, value) in shoppingList.enumerated() {
print("Item \(index + 1): \(value)")
print("アイテム \(index + 1): \(value)")
}
// Item 1: Six eggs
// Item 2: Milk
// Item 3: Flour
// Item 4: Baking Powder
// Item 5: Bananas
// アイテム 1: Six eggs
// アイテム 2: Milk
// アイテム 3: Flour
// アイテム 4: Baking Powder
// アイテム 5: Bananas
```

`for-in` ループについては、[For-In Loops\(For-In ループ\)](../language-guide/control-flow.md#for-in-loops)を参照ください。
Expand Down Expand Up @@ -257,8 +257,8 @@ Swift の基本的な型\(`String`、`Int`、`Double`、`Bool` など\)は、デ

```swift
var letters = Set<Character>()
print("letters is of type Set<Character> with \(letters.count) items.")
// letters is of type Set<Character> with 0 items.
print("letters \(letters.count) 個の要素を持つ Set<Character> 型です。")
// letters は 0 個の要素を持つ Set<Character> 型です。
```

> NOTE
Expand Down Expand Up @@ -306,19 +306,19 @@ var favoriteGenres: Set = ["Rock", "Classical", "Hip hop"]
セットのアイテムの数を調べるために、読み取り専用の `count` プロパティをチェックします。

```swift
print("I have \(favoriteGenres.count) favorite music genres.")
// I have 3 favorite music genres.
print("私には \(favoriteGenres.count) 個の好きな音楽ジャンがあります。")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("私には \(favoriteGenres.count) 個の好きな音楽ジャンがあります。")
print("私には \(favoriteGenres.count) 個の好きな音楽ジャンルがあります。")

// 私には 3 個の好きな音楽ジャンがあります。
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 私には 3 個の好きな音楽ジャンがあります
// 私には 3 個の好きな音楽ジャンルがあります

```

`Bool` 型の `isEmpty` プロパティは、`count` プロパティが `0` かどうかをチェックする簡略記法です。

```swift
if favoriteGenres.isEmpty {
print("As far as music goes, I'm not picky.")
print("音楽に関しては、こだわりはありません。")
} else {
print("I have particular music preferences.")
print("私には音楽の好みがあります。")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

上の文に合わせてこだわるという表現の方が良いかなあと思いました。

Suggested change
print("私には音楽の好みがあります。")
print("私は音楽にこだわりがあります。")

}
// I have particular music preferences.
// 私には音楽の好みがあります。
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 私には音楽の好みがあります
// 私には音楽にこだわりがあります

```

`insert(_:)` メソッドを使用して、セットに新しいアイテムを追加することができます。
Expand All @@ -332,22 +332,22 @@ favoriteGenres.insert("Jazz")

```swift
if let removedGenre = favoriteGenres.remove("Rock") {
print("\(removedGenre)? I'm over it.")
print("\(removedGenre)? もういいです。")
} else {
print("I never much cared for that.")
print("そのジャンルはあんまり気にしたことがないです。")
}
// Rock? I'm over it.
// Rock? もういいです。
```

特定のアイテムが含まれているかどうかを調べるには、`contains(_:)` メソッドを使用することができます。

```swift
if favoriteGenres.contains("Funk") {
print("I get up on the good foot.")
print("James BrownのGet On The Good Footは最高です!")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

意訳しました。
「いい足で起き上がる」だと意味が通じないので。
FunkといえばJames BrownのOn The Good Footなので、それがわかるようにしました。
https://www.youtube.com/watch?v=VgGwI12zMJg

} else {
print("It's too funky in here.")
print("ちょっとファンキー(funky)すぎます。")
}
// It's too funky in here.
// ちょっとファンキー(funky)すぎます。
```

### セットの繰り返し処理\(Iterating Over a Set\)
Expand Down Expand Up @@ -505,19 +505,19 @@ var airports = ["YYZ": "Toronto Pearson", "DUB": "Dublin"]
配列と同様に、`Dictionary` のアイテムの数を調べるために、読み取り専用の `count` プロパティをチェックします。

```swift
print("The airports dictionary contains \(airports.count) items.")
// The airports dictionary contains 2 items.
print("airports 辞書には \(airports.count) 個のアイテムがあります。")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

空港の一覧みたいなものがあるんですかね?airports も翻訳した方が良いかなあと思いました。

Suggested change
print("airports 辞書には \(airports.count) 個のアイテムがあります。")
print("空港辞書には \(airports.count) 個のアイテムがあります。")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

airports も翻訳した方が良いかなあと思いました。

この 「辞書リテラルを使った辞書の作成」章は airports dictionaryを定義して説明していく流れになっています。

本文も 「airports 辞書」と説明しているのでいるので「airports」はそのままにするほうがいいかなと思いました。

var airports: [String: String] = ["YYZ": "Toronto Pearson", "DUB": "Dublin"]

 // 本文もairports辞書で説明
`airports` 辞書は、`[String: String]` 型と宣言され、
「`String` 型のキーと `String` 型のバリューの `Dictionary`」を意味します。

```swift
var airports: [String: String] = ["YYZ": "Toronto Pearson", "DUB": "Dublin"]
```
`airports` 辞書は、`[String: String]` 型と宣言され、「`String` 型のキーと `String` 型のバリューの `Dictionary`」を意味します。

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あー、すいませんこれは完全に僕の勘違いですね🙇🏻‍♂️airportsのままで大丈夫です!

// airports 辞書には 2 個のアイテムがあります。
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// airports 辞書には 2 個のアイテムがあります。
// 空港辞書には 2 個のアイテムがあります。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同じく airports 辞書のままがいいかなと思いました。
#342 (comment)

```

`Bool` 型の `isEmpty` プロパティは、`count` プロパティが `0` かどうかをチェックする簡略記法です。

```swift
if airports.isEmpty {
print("The airports dictionary is empty.")
print("airports 辞書は空です。")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("airports 辞書は空です。")
print("空港辞書は空です。")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同じく airports 辞書のままがいいかなと思いました。
#342 (comment)

} else {
print("The airports dictionary isn't empty.")
print("airports 辞書は空ではありません。")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("airports 辞書は空ではありません。")
print("空港辞書は空ではありません。")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同じく airports 辞書のままがいいかなと思いました。
#342 (comment)

}
// The airports dictionary isn't empty.
// airports 辞書は空ではありません。
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// airports 辞書は空ではありません
// 空港辞書は空ではありません

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同じく airports 辞書のままがいいかなと思いました。
#342 (comment)

```

サブスクリプト構文を使用して、新しいアイテムを追加することができます。適切な型の新しいキーをサブスクリプトのインデックスに入れ、適切な型の新しいバリューを代入できます。
Expand Down Expand Up @@ -549,20 +549,20 @@ airports["LHR"] = "London Heathrow"

```swift
if let oldValue = airports.updateValue("Dublin Airport", forKey: "DUB") {
print("The old value for DUB was \(oldValue).")
print("DUB キーに対する更新前のバリューは \(oldValue) でした。")
}
// The old value for DUB was Dublin.
// DUB キーに対する更新前のバリューは Dublin でした。
```

サブスクリプト構文を使用して特定のキーのバリューを取得することもできます。バリューの存在しないキーに対してもリクエストすることが可能で、バリューの型のオプショナル値を返します。存在しなければ `nil` を返します:

```swift
if let airportName = airports["DUB"] {
print("The name of the airport is \(airportName).")
print("この空港の名前は \(airportName) です。")
} else {
print("That airport isn't in the airports dictionary.")
print("その空港は airports 辞書にはありません。")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print("その空港は airports 辞書にはありません。")
print("その空港は辞書にありません。")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「辞書(Dictionaries)」はずっと最初に airports dictionaryを一度定義してそれを使って説明する流れになっています。

var airports: [String: String] = ["YYZ": "Toronto Pearson", "DUB": "Dublin"]

なので、 「the airports dictionary.」は上の定義を指しているので「airports」は削らないほうがいいかなと思いました。
また、今までの訳では「airport/空港 辞書」で説明したところがいきなり「辞書」だけになると読者も同じものを指しているかが分かりくくなるかなと思いました。

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そのままで大丈夫です!

}
// The name of the airport is Dublin Airport.
// この空港の名前は Dublin Airport です。
```

サブスクリプト構文を使用して、キーに `nil` を代入することで、キーバリューペアを削除できます:
Expand All @@ -578,11 +578,11 @@ airports["APL"] = nil

```swift
if let removedValue = airports.removeValue(forKey: "DUB") {
print("The removed airport's name is \(removedValue).")
print("削除された空港の名前は \(removedValue) です。")
} else {
print("The airports dictionary doesn't contain a value for DUB.")
print("airports 辞書には DUB キーに対する値がありません。")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

airports いらないかもしれませんね。

Suggested change
print("airports 辞書には DUB キーに対する値がありません。")
print("辞書には DUB キーに対する値がありません。")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#342 (comment)
同じ理由で airportsは合ったほうがわかりやすいかなと思います

}
// The removed airport's name is Dublin Airport.
// 削除された空港の名前は Dublin Airport です。
```

### 辞書の繰り返し処理\(Iterating Over a Dictionary\)
Expand All @@ -603,26 +603,26 @@ for (airportCode, airportName) in airports {

```swift
for airportCode in airports.keys {
print("Airport code: \(airportCode)")
print("空港コード: \(airportCode)")
}
// Airport code: LHR
// Airport code: YYZ
// 空港コード: LHR
// 空港コード: YYZ

for airportName in airports.values {
print("Airport name: \(airportName)")
print("空港名: \(airportName)")
}
// Airport name: London Heathrow
// Airport name: Toronto Pearson
// 空港名: London Heathrow
// 空港名: Toronto Pearson
```

`Array` インスタンスを引数に受け取る API で辞書のキーとバリューを使いたい場合、`keys` と `values` プロパティを使用して新しい配列を初期化してください:

```swift
let airportCodes = [String](airports.keys)
// airportCodes is ["LHR", "YYZ"]
// 空港コードは ["LHR", "YYZ"]

let airportNames = [String](airports.values)
// airportNames is ["London Heathrow", "Toronto Pearson"]
// 空港名は ["London Heathrow", "Toronto Pearson"]
```

`Dictionary` 型には決まった順序がありません。特定の順番で値を繰り返し処理をしたい場合、`keys` か `values` プロパティの `sorted()` メソッドを使いましょう。
Expand Down