「今日は授業がない」と 先生から聞いたんだけど。
It is that I heard from the teacher, “There is no class today.” - this is the translation of this sentence from here Acting on relative clauses – Learn Japanese
I thought it would translate into something like this though - ‘but the teacher said’ “there i no class today” , adding the ‘but’ because だけど is at the end. What does the だけど do here?
It’s used to soften a statement to make it more polite. Like when you’re asking for directions, you don’t just walk up and demand help from a stranger, or exclaim I’m lost! as if it’s their job to help you. You would say something like, “I’m looking for the Tokyo Dome but…”
That’s how the けど works here. I heard there is no class, but… (I might be wrong? left unsaid). Also the ん in ~んだけど invites the listener to elaborate.