-
-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Add dir attribute for each locale #762
Comments
RTL always has so little support, so I'm happy to see it being brought up! I have a similar issue that I'm trying to resolve. I tried two different solutions, and both are unsatisfactory. I'm still fairly new to Nuxt, so I'm not 100% sure this is the right approach. It would be good to create a more "standard" way of solving the rtl problem. export default function({ app }) {
// beforeLanguageSwitch called right before setting a new locale
app.i18n.beforeLanguageSwitch = (oldLocale, newLocale) => {
app.head.htmlAttrs = {
lang: newLocale,
dir: newLocale == "ar" ? "rtl" : "ltr"
}
}
} Nevertheless, it would be great to have a |
Hey @rchl, I would really love to have your opinion 😊 |
Great idea and should be easy to do. :) |
You can also target the direction CSS property as a workaround - https://developer.mozilla.org/en-US/docs/Web/CSS/direction
|
@glenpike Using the HTML attribute is way much better than the CSS property 😊 |
Hi, yes, sorry, should have commented this was a workaround. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi @rchl, any news on this feature request? 😊 |
Is the feature already added? |
Resolved through #1023 and released in https://github.com/nuxt-community/i18n-module/releases/tag/v6.19.0. See the |
@rchl How can we get that property in pages or components? |
@aliwesome not sure what you mean exactly but you need to add this in the default layout or individual pages: export default {
head () {
return this.$nuxtI18nHead()
}
} |
I made this solution and worked fine:
This file will be imported to the nuxt.config.js file :
Then, Go to your nav component file and add this head function in your script to handle route changes:
|
@Mo7ammedMamdou7 |
Yes, bro thanks a lot for your support,
Then I added this code to default.vue layout file:
|
I wrote it on nuxt3(vue3) but I can't switch between dir and lang for each locale
|
you need to add this to your layout
|
Is your feature request related to a problem? Please describe.
I'm using this package to translate my app, and now I'm adding an RTL locale.
It would be great if nuxt-i18n could manage the body dir attribute.
Describe the solution you'd like
I propose to add a
dir
property for each locale in the module (values would bertl
,ltr
orauto
by default). For example:Then this would be added in the HTML by setting a new
dir
attribute at a very top level of the document, for example in the<html>
or<body>
tag. I think it's a mandatory feature for an i18n repo 😊Describe alternatives you've considered
As for now I'm using a custom plugin and adding the dir property as soon as I can:
What do you think? 😊
The text was updated successfully, but these errors were encountered: