The New Way to Build with AI! Introducing ReUI — the developer platform for agentic UI with shadcn/ui
Browse ReUI Pro

Metronic8 Angular demo1 dynamic RTL LTR switch at run time


Hello,

I read your documentation about RTL version of angular demo1 but it seems i can't make a switch from rtl to ltr at run time depending on language (Arabic language) is there any solution or work around to make this happened ?


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (5)

 
Deleted comment
 
Deleted comment
 
Deleted comment
 
Deleted comment
 
Deleted comment
 
Deleted comment
 
Deleted comment
 
Deleted comment
 
Deleted comment
 
Deleted comment
 
Deleted comment
 
Deleted comment

can we home same for REACT


Here is the possible solution:

  1. create <code>lltr.config.js</code> file (from copy of rtl.config.js) (comment <b>RtlCssPlugin</b> settings and for <code>MiniCssExtractPlugin</code> filename should be <code>'[name].ltr.css'</code>.
  2. in rtl and ltr configs comment rows [12-15] (no need to remove the older folder.
  3. in package json scripts add commands <code>"rtl": "webpack --config=rtl.config.js", "ltr": "webpack --config=ltr.config.js"</code>.
  4. Comment everything <code>src/styles.scss</code> file comment everything
  5. In any component you can have smth like this: <code>import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit, } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser';

@Component({

selector: 'your-component', templateUrl: './your.component.html', styleUrls: ['./your.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) export class YourComponent { direction: 'rtl' | 'ltr' = 'ltr';

constructor(private cd: ChangeDetectorRef, private sanitizer: DomSanitizer) {}

setDirection(_direction: 'rtl' | 'ltr') { this.direction = _direction; this.cd.detectChanges(); }

getCSSURL() { return this.sanitizer.bypassSecurityTrustResourceUrl( /assets/css/style.${this.direction}.css ); } } </code> 5) in the HTML of the component code can be next: <code> < link rel="stylesheet" [href]='getCSSURL()' > </code>

I've tried and it switches ltr => rtl and rtl => ltr in runtime.

Regards, Keenthemes support


Hi,

Maybe you can generate LRT and import both styles (RTL/LRT) together and somehow switch it, it can be a possible solution.

Regards,
Keenthemes support



Hi,

I try this way but the problem is I lose the imports that I include in angular.json file like import of indigo-pink.css material theme and throw an error that it can't find the material core theme and also sweetalert2 too and I'm trying to import those packages in style.rtl.css that generated by the webpack but I can't import them in the runtime because the scope of import is limited to assets folder not above it, is there any way to preserve the imports or import them in style.rtl.css and work ?



Hi,

Not sure how to help you with your custom request,
Anyway, will try to research your case by the end of the week (can't promise anything, but will try to implement it).

Regards,
Keenthemes support


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
buy metronic keenthemes mega bundle

ReUI

Open-source React components, blocks and templates built on shadcn/ui and Tailwind CSS by Keenthemes.