左から右の Web サイト用に作成された CSS ファイルが多数あります。
LTR のプロパティと値を対応する RTL に変換できる php 関数を作成したい
私がこれをやりたい理由は、ウェブサイトが常に開発中であり、数十のページとcssファイルがあり、それらすべてを追跡するのが非常に難しいためです.
この機能はCSSファイルを自動変換するのが目的なので、RTL版のWebサイトが作りやすくなります。
例えば:
// This is the content of the css file:
$content = '
html, body {
direction: ltr;
}
#element1 {
padding: 1px 2px 3px 4px;
margin-right: 3em;
background-position: 5% 80%;
background-image: url(image.png);
cursor: ne-resize;
text-align: left; /* 1 */
}
#element2 {
background: url(image.gif) 5% 80%;
text-align: right; /* 2 */
border-left: 1px solid #000;
}
';
$content = convertCSStoRTL($content);
// The output - This is what i want it to become after the function is applied to the content of the css file:
$content = '
html, body {
direction: rtl;
}
#element1 {
padding: 1px 4px 3px 2px;
margin-left: 3em;
background-position: 95% 80%;
background-image: url(image.png);
cursor: nw-resize;
text-align: right; /* 1 */
}
#element2 {
background: url(image.gif) 95% 80%;
text-align: left; /* 2 */
border-right: 1px solid #000;
}
';
PHPで(最も簡単な方法で)それを行うにはどうすればよいですか?