HARD "g" (girl): ga, ghe, ghi, go, gu, and the g+consonant
- diga (dam), dighe (dams), ghiro (dormouse), gomma (rubber), gustoso (tasty), grazie (thanks)
SOFT "g" (genuine): ge, gi
- gelato (ice cream), giovedì (thursday)
The rule does not change even with the double "gg"
- hard "g" - leggo (I read), leggono (they read)
- soft "g" - leggi (you read), legge (he/she reads), leggiamo (we read), leggete (you all read)
Furthermore, there are the particular combinations "gn" and "gli", where the "g" sound disappear completely forming two new sounds
- gnomo (gnome), ragno (spider)
- figlio (son), famiglia (family)
It's called verb conjugation - verbs change according to person and number. In English it's hardly present, but compare read vs reads, be/am/are/is and so on.
ere = to read
o= I read
i= you read (single person)
e= he/she read
iamo= we read
ete= you read (multiple people)
ono= they read
I'm italian and confirm that pronounce here is not the best available. Keith is right by saying that you can imagine a D before the G to understand better how to pause and stress the E, tough it is not an Italian rule. Anyway LEGONO with one G doesn't exist and if you use it it can be misunderstood for LEGANO (they tie)
It's the other way around - you don't pronounce them softly after certain vowels, you pronounce them softly before certain vowels. Legge is soft because the gg comes before e. Leggono is hard because the gg comes before o. It's being before an I or an E that makes the g soft.