I wondered why to say"sleep in the morning" just as "dormir le matin". I thought maybe it needs like "a" or other word to indicate "in". I mean, if I want to translate "Sometimes I sleep in the morning.", I would put a word between "dors" and "le". Anyone could give me a reason why there is no need for "in" in this sentence?
Yes. That sentence has a completely different meaning.
Sometimes I sleep in the morning = Parfois je dors le martin.
Sometimes I sleep through the morning = Parfois je dors a travers le matin.
The first sentence could imply that someone went to sleep in the morning. Whereas the second sentence implies that a person would sometimes not wake up in the morning, at all.
It's just how French speakers say it; it's a grammar rule. Putting the definite article « le » before a time of day or day of the week signifies a repeated action. Examples:
Je me suis promené ce matin. = I went for a walk this morning ; Je me promène le matin. = I go for a walk in the mornings (every morning).
On se verra ce soir. = We'll see each other tonight ; On se voit le soir. = We see each other in the evenings (every evening).
Nos grands-parents ont joué au badminton dimanche dernier. = Our grandparents played badminton last Sunday ; Nos grands-parents jouent encore au badminton le dimanche. = Our grandparents still play badminton on Sundays (every Sunday).
Je déteste le lundi. = I hate Mondays (every Monday).
There's nothing wrong with your sentence grammatically, but I think you are right that "to sleep in" already implies "in the morning" and therefore "to sleep in in the morning" sounds a bit redundant. Aside from that, I think the sentence "Parfois je dors le matin" just translates to "Sometimes I sleep in the morning," as in, "Usually I sleep at night but sometimes I sleep in the morning." To "sleep in" has a specialized meaning, namely, to deliberately sleep later than you usually do. I wouldn't assume that idea is implied by "dormir" by itself. If I had to guess, I would say that would be "Parfois je dors tard le matin."
I don't think sentences necessarily need to be useful for us to learn useful things. However this is a strange sentence so I assumed it could be translated as "Sometimes I sleep all morning" but this was rejected. I'm interested to know if that actually is a validf translation.
No, actually your translations convey a different meaning than this sentence. Parfois je dors le matin means "Sometimes I sleep in (during) the morning (as opposed to other times of the day, like the afternoon, evening, or night)." This is exactly what a person occasionally working the graveyard shift would say.
Your sentences, "Sometimes I sleep in in the morning" and "Some mornings I sleep in" are actually translated by the idiom faire la grasse matinée 'to sleep in (late)'. Parfois je fais la grasse matinée means what you typed. All that means is that you sleep later into the morning than usual.