I also faced this problem before Add default typst implementation code where possible · Issue #5095 · typst/typst · GitHub. You probably should open an issue about this.
// crates/typst-library/src/text/lang.rs
#let get-text-dir() = {
if text.dir != auto { return text.dir }
let rtl-langs = (
"ar",
"dv",
"fa",
"he",
"ks",
"pa",
"ps",
"sd",
"ug",
"ur",
"yi",
)
if text.lang in rtl-langs { rtl } else { ltr }
}
// #set text(dir: rtl)
// #set text(lang: "pa")
#context get-text-dir()
Also, please use the appropriate language identifier for code block in forum posts, as explained in How to post in the Questions category.