Clone this repo:
  1. 9a8aa4d build: Updating mediawiki/mediawiki-phan-config to 0.15.0 by libraryupgrader · 3 weeks ago master
  2. 9a4bf99 build: Updating phpunit/phpunit to 9.6.21 by libraryupgrader · 5 weeks ago
  3. d3c8c34 build: Updating mediawiki/mediawiki-codesniffer to 45.0.0 by libraryupgrader · 9 weeks ago
  4. eef248a test: Load test spec from Gerrit instead of GitHub and commit to repo by Hannah Okwelum · 2 months ago
  5. f8b6023 docs: Add a note about CSS Logical 1 by Ebrahim Byagowi · 5 months ago

Packagist

CSSJanus

Convert CSS stylesheets between left-to-right and right-to-left.

Usage

transform( string $css, bool $swapLtrInURL = false, bool $swapLeftInURL = false ) : string

Parameters;

  • $css (string) Stylesheet to transform.
  • $swapLtrInURL (boolean) Swap ltr to rtl direction in URLs.
  • $swapLeftInURL (boolean) Swap left and right edges in URLs.

Example:

$rtlCss = CSSJanus::transform( $ltrCss );

Preventing flipping

If a rule is not meant to be flipped by CSSJanus, use a /* @noflip */ comment to protect the rule.

.rule1 {
  /* Will be converted to margin-right */
  margin-left: 1em;
}
/* @noflip */
.rule2 {
  /* Will be preserved as margin-left */
  margin-left: 1em;
}

CSS Logical Properties

We encourage and recommend use of CSS logical properties for the subset of CSS features where a native direction-aware version of a CSS property exists (be sure to check browser support for specific properties). You can, for example, set properties like margin-inline-start instead of margin-left, which the browser flips based on content direction, and work seamlessly alongside other CSS properties that CSSJanus flips instead.

Note that CSS logical properties flip based on nearest content direction and content language, whereas CSSJanus is generally configured to flip by user language and UI direction.

Port

This is a PHP port of the Node.js implementation of CSSJanus. Feature requests and bugs related to the actual CSS transformation logic or test cases of it, should be submitted upstream at https://github.com/cssjanus/cssjanus.

CSSJanus was originally a Google project.

Contribute

  NODES
node.js 1
Note 2