Skip to content

Conversation

mnouraei
Copy link

This change adds functionality to check if the current culture is right-to-left (RTL) and replace the CSS file with its corresponding .rtl.css version if it exists.

This approach allows RTL-specific styles to be kept in separate CSS files rather than merging them into the main CSS, which:

  • Prevents bloating the default CSS files with RTL overrides
  • Improves site performance by loading only necessary styles
  • Keeps RTL styles modular and easier to maintain

In summary, it optimises loading for RTL cultures by using dedicated .rtl.css files when available.

Note: This approach has been tested and used for over 4 years in the repository below without issues:
Persian-DnnSoftware/ClientDependency

@mnouraei mnouraei marked this pull request as ready for review July 12, 2025 03:57
@codecupis
Copy link

This is an excellent addition! The ability to automatically load .rtl.css stylesheets for RTL cultures should have been implemented from the beginning. Having framework-level support for culture-specific styling will give us much better control over layouts and templates, especially in multilingual applications.

This feature will significantly improve the development experience for RTL languages and will likely encourage more widespread adoption of the platform. It's great to see this finally being addressed after all these years. Thank you for listening to community needs and making this enhancement!

@uzmannazari
Copy link

Thank you for this PR!
As a developer from Iran, I can confirm that we have been using this exact approach for years in almost all major RTL websites and enterprise DNN projects. Managing RTL styles in dedicated .rtl.css files (instead of merging them into the main CSS) is a de-facto standard for Persian and Arabic web projects. This not only keeps stylesheets maintainable, but also has a significant positive impact on site performance and user experience for RTL users.

Honestly, this feature is absolutely essential for any serious multi-lingual DNN implementation that wants to support RTL languages properly. We truly need this in the core!

Thank you again for your effort.
Strongly support merging this PR.

@arminrahimian
Copy link

Thanks for suggesting this feature! @mnouraei
As a developer working in an RTL-first environment, I can say this is the recommended and widely-used method in real-world projects.

Keeping .rtl.css files separate—rather than mixing RTL styles into the main CSS—is crucial for building scalable, maintainable, and fast-loading websites that support RTL users.

This PR is spot on:

  • Keeps default CSS files clean and lightweight
  • Loads only what's necessary, improving performance
  • Makes long-term maintenance much easier

I fully support merging this into the DNN core.
Native RTL support like this is long overdue!

@hrezazadeh-aryaportal
Copy link

Automatic support for .rtl.css files for right-to-left (RTL) languages has long been an essential need in multilingual DNN-based projects.
It’s great to finally see this implemented at the framework level — a feature that really should have been in the DNN core from the start.

As developers working in RTL-first environments for years, we can confidently say that separating RTL styles into dedicated .rtl.css files is not just a best practice — it’s already the de facto standard in real-world Persian and Arabic web projects.

This approach significantly:

Keeps the main CSS clean and maintainable

Loads only what’s necessary for RTL users

Improves overall site performance

Integrating this feature into the DNN core will greatly enhance the development experience for RTL languages and enable scalable, professional support for RTL users.

Thank you for recognizing the real needs of the community and proposing this pull request.
I fully support merging it into the DNN core — this is a crucial step toward true internationalization of the platform.

@Behnam-Emamian
Copy link

Hey @valadas
Build issue has been fixed, I believe we need to increase the version to 1.9.11, could you please give me your advice?

@shahubofficial
Copy link

Appreciation for Your Outstanding Contribution to the PR Project

Dear Engineer Noraei,

Your dedicated efforts and expertise had a significant impact on the success of the PR project. Your precision, professionalism, and commitment throughout the process were truly commendable. I sincerely thank you for the time and energy you devoted to this work.

We truly value the collaboration between you and the DNN team, and we strongly encourage the continuation of this productive partnership in future projects.

With appreciation,
[Shahubofficial]

@valadas
Copy link

valadas commented Jul 13, 2025

I am not a big fan of serving whole different css just before of text direction myself. That would mean having to duplicate everything else that is not specific to text direction. Another PR was submitted to provide the text direction as an html attribute and a class on the body. I believe css selectors should be used instead of completely different files.

@mnouraei
Copy link
Author

@valadas
I completely understand your concern. Naturally, increasing the number of files in the project may not seem ideal. However, it is important to note that this approach covers both scenarios: whether a separate RTL file exists or not.

In the previous PR that you approved, I mentioned that I am planning to gradually apply my 6 years of experience working with this repository along with over 15 years of expertise in DNN to enhance this system and add proper support for right-to-left languages.

This solution has been carefully evaluated over the years and has been successfully used and welcomed by many governmental and non-governmental organizations. Therefore, as someone who has been actively involved in this community for a long time, I believe this feature is highly essential, which is why I proposed adding it to the core after all these years.

I kindly ask you to consider this with an open mind and approve this change.

@mohammadrazani
Copy link

Thanks for proposing this change! As someone working with RTL languages, I can confirm that separating RTL styles into dedicated .rtl.css files makes a big difference in terms of maintainability and performance. It keeps the main CSS clean and avoids unnecessary bloat, and only loads what's needed for RTL languages, which improves both performance and load times.

I fully support merging this PR into the DNN core. Proper RTL support is a practical improvement for many projects, and this solution seems like the right way forward.

@BonyaviD
Copy link

"Great implementation! This approach strikes a perfect balance between performance optimization and maintainability. By isolating RTL-specific styles into separate CSS files, you not only avoid unnecessary bloat in the default CSS but also enhance the scalability of the site for different cultural settings. It's clear that you've taken a practical and future-proof approach, especially with the emphasis on modularity. I also appreciate the note on the long-term successful implementation—always reassuring to see solutions that have stood the test of time. Awesome work!"

@azarbara
Copy link

@mnouraei thanks a lot for this valuable contribution
Using separate .rtl.css files is a smart and efficient solution for improving RTL support — especially in projects where performance and maintainability matter. From my own experience in multilingual UI development, keeping styles modular and direction-specific really makes a difference.
@valadas I hope this PR can be considered with an open mind and approved — I truly believe it enhances the core in a meaningful way for RTL users across the globe.

@bdukes
Copy link

bdukes commented Jul 15, 2025

Is dnnsoftware/Dnn.Platform#6622 still required if this change is in place? It seems like they're both doing the same thing

dependency.FilePath = basePath + dependency.FilePath;

// Replace CSS file with its RTL version if the current culture is right-to-left and the RTL file exists
if (System.Globalization.CultureInfo.CurrentCulture.TextInfo.IsRightToLeft && dependency.FilePath.EndsWith(".css", StringComparison.OrdinalIgnoreCase) && !dependency.FilePath.Contains("http"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible/suggested that we need to support this for JS dependencies as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion, it would be great if this feature is supported for JS as well.
However, I haven’t tested this yet to be able to confidently create a PR for it.

@mnouraei
Copy link
Author

Is dnnsoftware/Dnn.Platform#6622 still required if this change is in place? It seems like they're both doing the same thing

I also mentioned in PR dnnsoftware/Dnn.Platform#6622 that these two behaviors are different and this check needs to be done in both places.

@bdukes
Copy link

bdukes commented Jul 18, 2025

I've pushed a change which makes the RTL replacement happen in all cases (I tested with default.css), so that there does not need to be a corresponding change in DNN.Platform

@bdukes
Copy link

bdukes commented Jul 18, 2025

I also made it more general, so that it works with any file extension, not just CSS.

@mnouraei
Copy link
Author

mnouraei commented Jul 19, 2025

Very nice, these changes look great. Based on the changes you’ve made, if I understand correctly, we no longer need to modify the ClientResourceManager.cs class (DNN.Platform). Is that correct?

@mnouraei mnouraei requested review from bdukes July 19, 2025 08:27
@mnouraei
Copy link
Author

@bdukes
This review request was assigned to me by mistake. Unfortunately, I don’t have the necessary permissions to remove it myself. Could you please remove this review request from me? Thank you.

Copy link

@valadas valadas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, after discussions, I agree with this PR.

@bdukes
Copy link

bdukes commented Jul 22, 2025

@mitchelsellers can you give another set of eyes on this (since I rewrote things, my approval probably shouldn't count)?

@valadas once this is in, we'll also need to bump the version and release, and then pull that new version in the Dnn.Platform code.

@mitchelsellers mitchelsellers merged commit 7bf46d9 into dnnsoftware:dnn Jul 29, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.