WooCommerce RTL Support
-
A great number of WooCommerce-powered online stores aren’t in English. We all know that WooCommerce community care about internationalization (i18n). Therefore, supporting RTL (right-to-left) alignment is quite necessary for languages like Arabic, Persian, Urdu, and many others.
For a while now, I’ve been working to add this support to WooCommerce, and I would like to show you how would a RTL WooCommerce store will look with and without RTL adjustments:
Without RTL adjustments (Original WooCommerce Plugin): https://drp.io/ail/cKc/-/-
With RTL adjustments (Modified WooCommerce Plugin): https://drp.io/aim/cKn/-/-
As you can see, the Original Plugin doesn’t handle RTL alignment that well. It is messy and illogical for RTL readers.
Here are the steps I followed to make WooCommerce RTL-ready (After each update, ugh…):
-Download the latest version and replace the old plugin folder with the new one. -Add a new folder in assets/css with the name “rtl” and copy all the .css stylesheets into it. (DON'T COPY 'chosen.css', LEAVE IT). -Configure CSS loaders to detect RTL language and load the needed stylesheets from assets/css/rtl via “isrtl” function. -Edit "class-wc-admin-notices.php” and "class-wc-admin-welcome.php” to load “rtl/activation.css”. -Edit "class-wc-admin-assets.php” to load “rtl/admin.css”. -Edit "class-wc-frontend-scripts.php” to load “rtl/prettyPhoto.css”. -Edit "class-wc-admin-assets.php” to load “rtl/dashboard.css” & “rtl/menu.css”. -Edit "class-wc-frontend-scripts.php” and add an array to each .css file in “woocommerceenqueuestyles” with the name “rtlsrc” to load “rtl/{filename.}.css”. -Edit the “foreach” for the variable “$enqueuestyles” to load “rtlsrc” if the language is RTL in "class-wc-frontend-scripts.php". -RTL each .css file in “assets/css/rtl”. -Find and replace “../“ with “../../“ for all .css files in “css/rtl”. -Reverse “tabs” style to LTR. -Make “.productdimensions” and “.product_weight” classes “dir: ltr”. -Edit "my-orders.php” file “text-align: left” to be RTL friendly. -Edit all .php files under “templates/emails” text-algin from “left” to “right” if is RTL. -Edit “includes/abstracts/abstract-wc-email.php” text-align from “left” to “right” if is RTL. -Load “chosen-rtl.js” to the fontend & edit it so it work on the class “.chosen-container”. -Replace arrows between the classes ".wc-forward” and ".wc-backward” in “woocommerce.css” -Prettify “prettyPhoto.css” & fix its arrows & flip the “close” and “expand” buttons to be at a proper position.
(The steps above will add full RTL support to the dashboard, the front-end, and the email templates).
To try the RTL version of WooCommerce, download it now (2.2.4): https://cl.ly/4339150E3g35/download/woocommerce.zip
My point of all of this is to explain how RTL support is very important and should be integrated with the main plugin. It’s really not that hard to add, and doesn’t affect the plugin size what so ever.
Thank you.
- The topic ‘WooCommerce RTL Support’ is closed to new replies.