Breakdown of O menino dormia quando apanhou um susto e gritou.
e
and
um
a / an / some (all forms)
quando
when
dormir
to sleep
Questions & Answers about O menino dormia quando apanhou um susto e gritou.
Why do we use dormia (imperfect) here instead of dormiu (perfect)?
Dormia is the Pretérito Imperfeito (Imperfect tense). We use it here because the boy "was sleeping" — it was an ongoing, background action in the past. If we used dormiu, it would mean he completed the entire action of sleeping, like "he slept".
Why do the verbs switch to the perfect tense for apanhou and gritou?
Because these are sudden, completed actions that happened while he was sleeping. When a specific event interrupts an ongoing background action, we use the Pretérito Perfeito Simples for that interruption. The ongoing sleeping was interrupted when he "got" a fright and "shouted".
I thought apanhar meant "to catch". Why does it mean "got" here?
You are right, apanhar usually translates to "to catch". However, Portuguese uses the fixed expression apanhar um susto (literally "to catch a fright") to mean "to get a fright" or "to be startled".