Temporary nextjs repo for testing RTL using styled-jsx
This is an URL based approach on switching locale/language with nextjs.
The main concern here is applying the required RTL CSS when needed. Along with right-aligining the text; borders, padding, margins and other styles should also be changed as needed to display the content correctly.
The approach is summarized as follows:
- Use a custom server and routes to accomodate
localhost:3000/en/<route>
andlocalhost:3000/ar/<route>
. - Pass the locale key from the requested URL to components to determine the direction.
- Set the
dir
attribute forhtml
accordingly. - Use CSS selectors in the format
:global(html[dir=rtl]) .someClass
to apply required styles.
Use npm run dev
to start the development server locally