Next.jsAdvanced
Right-to-left languages
Right-to-left (rtl) languages are those that are read and written from right to left.
Languages written from right to left have a combined total of over 500 million speakers worldwide. They include:
- Arabic (
ar
) - Hebrew (
he
) - Persian (
fa
) - Urdu (
ur
)
The generaltranslation
language infrastructure library
offers a getLanguageDirection()
function to determine if a language goes "rtl"
or "ltr"
.
In gt-next
use the getLocale()
function to get the locale in the root layout, then add the lang
and dir
props to the <html>
tag:
Alternately, if you're using i18n routing, you could get the locale from the params:
This will change the direction of the text on the screen when the website is accessed in certain languages.