[Feature Request] Add dir attribute for each locale
See original GitHub issueIs 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 be rtl
, ltr
or auto
by default). For example:
// nuxt.config.js, inside nuxt-i18n module
locales: [
{ code: 'ar', iso: 'ar', file: 'ar/app.js', dir: 'rtl' },
{ code: 'en', iso: 'en-US', file: 'en/app.js', dir: 'ltr' },
{ code: 'fr', iso: 'fr-FR', file: 'fr/app.js', dir: 'ltr' },
],
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:
// plugins/ltr-rtl.js
export default function({ app }, inject) {
const dir = () => app.i18n.locales.find((x) => x.code === app.i18n.locale)?.dir;
inject( 'dir', dir);
}
<!-- layouts/default.vue -->
<div id="app" :dir="$dir()">
My app here...
</div>
What do you think? 😊
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:15
Top Results From Across the Web
[Feature Request] Add dir attribute for each locale #762 - GitHub
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...
Read more >HTMLElement.dir - Web APIs | MDN
The HTMLElement. dir property gets or sets the text writing directionality of the content of the current element. The text writing ...
Read more >Tutorial - Customize Azure Active Directory attribute mappings ...
Select an existing Attribute Mapping to open the Edit Attribute screen. Here you can edit the user attributes that flow between Azure AD...
Read more >How to set Locale for Transformation - Oxygen XML Forum
You should set the locale in the DITA source files by setting the xml:lang attribute at the DITA map level (for example by...
Read more >Localized Versions of your Pages | Google Search Central
Add <link rel="alternate" hreflang=" lang_code "... > elements to your page header to tell Google all of the language and region variants of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, bro thanks a lot for your support, This is the configuration I made and worked fine: First, I add this code to the i18n config in the nuxt.config.js file:
Then I added this code to default.vue layout file:
@Mo7ammedMamdou7 it’s now supported out of the box. https://i18n.nuxtjs.org/options-reference/#locales Ref: https://github.com/nuxt-community/i18n-module/pull/1023