fix: Bring back dir attr using Intl (#11806)
Co-authored-by: Omar López <zomars@me.com>pull/11808/head
parent
303073822c
commit
ff3a9d03a4
|
@ -50,9 +50,18 @@ class MyDocument extends Document<Props> {
|
||||||
|
|
||||||
const nonceParsed = z.string().safeParse(this.props.nonce);
|
const nonceParsed = z.string().safeParse(this.props.nonce);
|
||||||
const nonce = nonceParsed.success ? nonceParsed.data : "";
|
const nonce = nonceParsed.success ? nonceParsed.data : "";
|
||||||
|
|
||||||
|
const intlLocale = new Intl.Locale(newLocale);
|
||||||
|
// @ts-expect-error INFO: Typescript does not know about the Intl.Locale textInfo attribute
|
||||||
|
const direction = intlLocale.textInfo?.direction;
|
||||||
|
if (!direction) {
|
||||||
|
throw new Error("NodeJS major breaking change detected, use getTextInfo() instead.");
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Html
|
<Html
|
||||||
lang={newLocale}
|
lang={newLocale}
|
||||||
|
dir={direction}
|
||||||
style={embedColorScheme ? { colorScheme: embedColorScheme as string } : undefined}>
|
style={embedColorScheme ? { colorScheme: embedColorScheme as string } : undefined}>
|
||||||
<Head nonce={nonce}>
|
<Head nonce={nonce}>
|
||||||
<script
|
<script
|
||||||
|
|
Loading…
Reference in New Issue