backdrop-contrib / ubercart

A flexible but easy-to-use e-commerce system for Backdrop.
https://backdropcms.org/project/ubercart
GNU General Public License v2.0
4 stars 10 forks source link

RTL CSS in uc_cart? #475

Open bugfolder opened 12 months ago

bugfolder commented 12 months ago

The uc_cart submodule contains CSS files for RTL:

But I don't see anywhere in the code that actually loads these.

Should we be doing something like this in all the places where we currently load the non-RTL files?

  $language = isset($GLOBALS['language']) ? $GLOBALS['language'] : language_default();
  // load -rtl CSS file if $language->direction == `rtl, otherwise load non-rtl CSS file
bugfolder commented 9 months ago

The above is not quite right. The *-rtl.css files are deltas, not replacements; i.e., they should be loaded in addition to the non-RTL css files.

And there are several modules that have *-rtl.css files, including:

None of these files are loaded anywhere in Ubercart.

Typically, a CSS file is either included in the .info file, or loaded via something like this:

  backdrop_add_css(backdrop_get_path('module', 'uc_cart') . '/css/uc_cart.css');

Since we would need to check the language anywhere we're loading a file that has an RTL version, I suggest we create a utility routine that we can call to load a CSS file that automatically checks the language and, if appropriate, looks for a file with an -rtl suffix and loads that as well. Then we can go through all of Ubercart and replace backdrop_add_css() with our utility function.

argiepiano commented 9 months ago

@bugfolder, this sounds like a good plan to me.