-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
lesson-28-specifying-types.pot
204 lines (179 loc) · 6.86 KB
/
lesson-28-specifying-types.pot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# Translations template for Learn GDScript From Zero.
# Copyright (C) 2024 GDQuest
# This file is distributed under the same license as the Learn GDScript From
# Zero project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2024.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Learn GDScript From Zero \n"
"Report-Msgid-Bugs-To: https://github.com/GDQuest/learn-gdscript\n"
"POT-Creation-Date: 2024-12-12 14:39+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.10.1\n"
#: course/lesson-28-specifying-types/lesson.tres:13
msgid ""
"By default, GDScript is what we call a dynamically-typed language. That "
"means that you can just write variables, assign them a value with a "
"number, and assign them another value with a different type.\n"
"\n"
"Unlike in some other languages, in GDScript, the following code is valid."
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:35
msgid ""
"But this feature often causes problems down the line. Let's take one "
"example."
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:43
msgid "Cell size: decimal number, or 2D vector?"
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:45
msgid ""
"Games use grids all the time, be it for grid-based gameplay or to make "
"algorithms faster.\n"
"\n"
"When working with grids, you need to convert grid coordinates into "
"positions in the game world all the time. To do so, you give each cell a "
"size in pixels.\n"
"\n"
"You'll likely pick one of two types for that: [code]float[/code] or "
"[code]Vector2[/code], because pixel positions on the screen use "
"[code]Vector2[/code] coordinates.\n"
"\n"
"Either of those two values would be fine:"
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:71
msgid ""
"Using a [code]Vector2[/code] could simplify some calculations. For "
"example, when converting grid coordinates to game world coordinates."
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:91
msgid ""
"In this example, because both [code]cell[/code] and "
"[code]cell_size[/code] are [code]Vector2[/code] values, we can add them."
"\n"
"\n"
"However, if [code]cell_size[/code] is a [code]float[/code], we will get a"
" type error."
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:123
msgid ""
"Worse: due to dynamic typing, we won't get an error [i]right away[/i]. We"
" will only get the error when calling [code]grid_to_world(Vector2(1, "
"1))[/code].\n"
"\n"
"And that's a big problem."
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:135
msgid ""
"Because we're learning, we only have small code examples in this course. "
"But your games' code will get long and split into many files. When "
"coding, you often forget about the code you wrote several weeks ago.\n"
"\n"
"And with a lot of code, it could take [i]hours[/i] of play before players"
" trigger a type error in your code."
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:145
msgid "Using type hints"
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:147
msgid ""
"Fortunately, GDScript has optional [i]type hints[/i].\n"
"\n"
"Type hints let the computer know the value type you want for variables "
"and report errors before running the code.\n"
"\n"
"To specify the type a variable can accept, you can write a colon and a "
"type after the name when defining a new variable."
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:171
msgid ""
"You could tell the computer you want [code]cell_size[/code] only to "
"accept [code]Vector2[/code] values like so."
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:191
msgid ""
"If you try to replace the [code]cell_size[/code] with a value of another "
"type later, the computer will not let you."
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:219
msgid "Letting the computer figure it out"
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:221
msgid ""
"GDScript comes with a feature called [i]type inference[/i]. In many "
"cases, but not all, the computer can figure out the type of a variable "
"for you.\n"
"\n"
"To do so, you write [code]:=[/code], without the type. The computer will "
"set the type using the value after the equal sign. We could make "
"[code]cell_size[/code] a variable of type [code]Vector2[/code] like so:"
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:243
msgid ""
"This takes little typing, yet you get the benefits of using type hints, "
"like the computer reporting errors better and faster."
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:251
msgid "Why bother to add hints?"
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:253
msgid ""
"When you give the language hints like that, it will [i]prevent[/i] major "
"type errors. When you work in Godot, you will see that the computer can "
"report issues as you write the code. It makes the benefit even greater.\n"
"\n"
"Type hints can also help improve the readability of your code. It can "
"help to put more information directly in the code. As we saw, types are "
"essential when coding, and when using type hints, the computer will add "
"them to the engine's built-in code documentation system.\n"
"\n"
"There's an incredible third benefit for you: by using type hints, you "
"will learn types much faster. It's excellent for learning.\n"
"\n"
"In the following practices, you will write the correct type hints to make"
" the code error-free."
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:267
msgid "Add the correct type hints to variables"
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:268
msgid ""
"Our variables get the correct values but not the right hints. Using your "
"type-fu, add the correct type names in the variable definitions.\n"
"\n"
"You need to write the type name between the colon and the equal sign.\n"
"\n"
"Note: You cannot use type inference in this practice. You need to write "
"the type name in full."
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:284
msgid ""
"Our variables have the wrong type hints, causing errors. Correct them to "
"make the code run."
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:289
msgid "Fix the values to match the type hints"
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:290
msgid ""
"It is the other way around in this practice: the type hints are fine, but"
" the values are not.\n"
"\n"
"Your task is to fix the values after the equal sign, so they match the "
"type hint of each variable."
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:304
msgid ""
"This time, it's the other way around: variables have the correct type "
"hints but the wrong values. Change the values to make the code run."
msgstr ""
#: course/lesson-28-specifying-types/lesson.tres:308
msgid "Specifying types with type hints"
msgstr ""