{"id":5890,"date":"2025-05-16T15:24:11","date_gmt":"2025-05-16T20:24:11","guid":{"rendered":"https:\/\/frontendmasters.com\/blog\/?p=5890"},"modified":"2025-05-16T15:24:12","modified_gmt":"2025-05-16T20:24:12","slug":"to-flip-or-not-to-flip","status":"publish","type":"post","link":"https:\/\/frontendmasters.com\/blog\/to-flip-or-not-to-flip\/","title":{"rendered":"Is there a Correct Answer? Flipping Layouts When Google Translate Swaps between a Left-to-Right Language and a Right-to-Left Language"},"content":{"rendered":"\n<p><a href=\"https:\/\/chriscoyier.net\/\">My personal website<\/a> was designed in English, because that&#8217;s the only language I speak. English is a left-to-right language (LTR). <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"888\" src=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-7.52.17%E2%80%AFAM.png?resize=1024%2C888&#038;ssl=1\" alt=\"\" class=\"wp-image-5901\" srcset=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-7.52.17%E2%80%AFAM-scaled.png?resize=1024%2C888&amp;ssl=1 1024w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-7.52.17%E2%80%AFAM-scaled.png?resize=300%2C260&amp;ssl=1 300w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-7.52.17%E2%80%AFAM-scaled.png?resize=768%2C666&amp;ssl=1 768w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-7.52.17%E2%80%AFAM-scaled.png?resize=1536%2C1332&amp;ssl=1 1536w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-7.52.17%E2%80%AFAM-scaled.png?resize=2048%2C1776&amp;ssl=1 2048w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<p>Anybody can translate the website though. There are a variety of site translation tools. I don&#8217;t have any data on popularity, but I gotta imagine <a href=\"https:\/\/translate.google.com\/?source=gtx&amp;sl=ar&amp;tl=en&amp;op=translate\">Google Translate<\/a> is up there, which is a website and Chrome Extension and, to some degree, automatic translation is just built into Chrome (and other browsers).<\/p>\n\n\n\n<p>So let&#8217;s say I translate my website from English to Arabic, a right-to-left language (RTL). Here&#8217;s what I get: <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"896\" src=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-7.51.41%E2%80%AFAM.png?resize=1024%2C896&#038;ssl=1\" alt=\"\" class=\"wp-image-5902\" srcset=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-7.51.41%E2%80%AFAM.png?resize=1024%2C896&amp;ssl=1 1024w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-7.51.41%E2%80%AFAM.png?resize=300%2C262&amp;ssl=1 300w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-7.51.41%E2%80%AFAM.png?resize=768%2C672&amp;ssl=1 768w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-7.51.41%E2%80%AFAM.png?resize=1536%2C1344&amp;ssl=1 1536w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-7.51.41%E2%80%AFAM.png?resize=2048%2C1792&amp;ssl=1 2048w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<p>It&#8217;s the exact same layout, it&#8217;s just the words are in Arabic now. Which is not terribly surprising, I guess? But even the alignments have stayed the same, so this RTL language is still being show in an LTR way. <\/p>\n\n\n\n<p>Google Translate, aside from the text node translation, makes a few other changes that are notable here. What used to be:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html<\/span> <span class=\"hljs-attr\">lang<\/span>=<span class=\"hljs-string\">\"en\"<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Becomes:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html<\/span> <span class=\"hljs-attr\">lang<\/span>=<span class=\"hljs-string\">\"ar\"<\/span> <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"translated-rtl\"<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Those changes <em>do not actually change the direction to RTL.<\/em> It <em>could<\/em> have, like:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-code-table\"><span class='shcb-loc'><span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html<\/span> <\/span>\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-tag\">  <span class=\"hljs-attr\">lang<\/span>=<span class=\"hljs-string\">\"ar\"<\/span> <\/span>\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-tag\">  <span class=\"hljs-attr\">class<\/span>=<span class=\"hljs-string\">\"translated-rtl\"<\/span> <\/span>\n<\/span><\/span><mark class='shcb-loc'><span><span class=\"hljs-tag\">  <span class=\"hljs-attr\">dir<\/span>=<span class=\"hljs-string\">\"rtl\"<\/span><\/span>\n<\/span><\/mark><span class='shcb-loc'><span><span class=\"hljs-tag\">&gt;<\/span>\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Or it could have injected CSS like:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-class\">.translated-rtl<\/span> {\n  <span class=\"hljs-attribute\">direction<\/span>: rtl;\n}\n\n<span class=\"hljs-comment\">\/* or *\/<\/span>\n\n<span class=\"hljs-selector-attr\">&#91;lang=<span class=\"hljs-string\">\"ar\"<\/span>]<\/span> {\n  <span class=\"hljs-attribute\">direction<\/span>: rtl;\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>But it doesn&#8217;t. I don&#8217;t know for sure, but my guess is that it intentionally doesn&#8217;t do that, because it jacks up more layouts than it helps.<\/p>\n\n\n\n<p>But let&#8217;s say you&#8217;re <em>me<\/em> (perfect, handsome) and you&#8217;ve changed your muscle memory for writing a lot of CSS properties to using <a href=\"https:\/\/frontendmasters.com\/courses\/pro-css\/css-reset\/?t=460&amp;utm_source=boost&amp;utm_medium=blog&amp;utm_campaign=boost\">logical properties<\/a>. That is, stuff like <code>padding-inline-start<\/code> instead of <code>padding-left<\/code>, and the like. That, plus using layout like flexbox and grid, will reflow naturally with direction changes. So if you change the direction to <code>rtl<\/code> on <em>my<\/em> site, you get:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"884\" src=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-8.04.20%E2%80%AFAM.png?resize=1024%2C884&#038;ssl=1\" alt=\"\" class=\"wp-image-5903\" srcset=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-8.04.20%E2%80%AFAM-scaled.png?resize=1024%2C884&amp;ssl=1 1024w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-8.04.20%E2%80%AFAM-scaled.png?resize=300%2C259&amp;ssl=1 300w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-8.04.20%E2%80%AFAM-scaled.png?resize=768%2C663&amp;ssl=1 768w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-8.04.20%E2%80%AFAM-scaled.png?resize=1536%2C1326&amp;ssl=1 1536w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/Screenshot-2025-05-16-at-8.04.20%E2%80%AFAM-scaled.png?resize=2048%2C1768&amp;ssl=1 2048w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><figcaption class=\"wp-element-caption\">The whole layout flips.<\/figcaption><\/figure>\n\n\n\n<p>So the question is:<\/p>\n\n\n\n<p class=\"has-large-font-size\"><strong>Is that <\/strong>&#8220;<strong>better&#8221;?<\/strong><\/p>\n\n\n\n<p>Meaning: does it read better for native Arabic speakers? Does it generally <em>feel<\/em> better or more native? Or is it worse, in that it&#8217;s unexpected or unnatural somehow? <\/p>\n\n\n\n<p>I have a friend who speaks\/reads Arabic, just for one anecdotal bit of data. I showed them a site and translated it, and they were like &#8220;it&#8217;s fine&#8221;. But then I showed them a tweaked one where things like the header and hero text and stuff was actually flipped, and they thought it was better. They were like &#8220;I never actually see this done, but it&#8217;s better this way.&#8221;<\/p>\n\n\n\n<p>It&#8217;s likely that this no One True Answer here. Even if you&#8217;ve done a good job with a layout that flips and looks sensible. <a href=\"https:\/\/topspicy.social\/@alda\/114501106378371396\">Alda Vigd\u00eds told me<\/a>: <\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>As someone who has worked on bi-lingual content, dir=&#8221;rtl&#8221; should of course be indicated for textual content, but the layout question depends on a lot more factors.<\/p>\n\n\n\n<p>Arabic and Hebrew speaking power users often prefer to have a ltr-oriented layout, while some other groups prefer rtl-oriented layout.<\/p>\n<\/blockquote>\n\n\n\n<p>So it may just be a matter of preference of individuals, which is more evidence for why Google Translate doesn&#8217;t go there (for layout). Perhaps they should be trying to find more fine-grained text nodes and flipping the <code>dir<\/code> there, but they don&#8217;t do that either. <\/p>\n\n\n\n<p>If you land on &#8220;leave the layout alone, but flip the <code>dir<\/code> for text&#8221;, like Alda suggests, it would be a bring-your-own-CSS situation. You could use Google Translate&#8217;s class and flip just the text you need to, like:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-class\">.translated-rtl<\/span> {\n  p, li, dt, dd, td, th, h1, h2, h3 {\n    <span class=\"hljs-attribute\">direction<\/span>: rtl;\n  }\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>That feels a little \ud83d\ude2c to me, like you&#8217;ll miss some and make it worse instead of better or something. (I just picked those selectors randomly quick, to illustrate.) So much testing needed.<\/p>\n\n\n\n<p>A flipped layout can be preferable even here though, as <a href=\"https:\/\/indieweb.social\/@nmn\/114503173952548664\">Naman told me<\/a>:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>There are somethings that work both ways. The sidebar can be on either side and it makes sense.<\/p>\n\n\n\n<p>But something like the search bar makes a lot more sense with the layout flipped. [Also: headings in the sidebar are also a lot better with the layout flipped]<\/p>\n\n\n\n<p>On balance, I think yes, flipping has an overall better result.<\/p>\n<\/blockquote>\n\n\n\n<p>So if you&#8217;re looking for a straight answer, I&#8217;m afraid I can&#8217;t give you one. Except, ya know, do a good job.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Google Translate doesn&#8217;t change the `dir` of a site when translating from LTR to RTL&#8230; but you could.<\/p>\n","protected":false},"author":1,"featured_media":5908,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[7,31,53,347,348],"class_list":["post-5890","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-post","tag-css","tag-html","tag-layout","tag-logical-properties","tag-translation"],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/ChatGPT-and-the-proliferation-of.jpg?fit=1140%2C676&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/5890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/comments?post=5890"}],"version-history":[{"count":7,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/5890\/revisions"}],"predecessor-version":[{"id":5910,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/5890\/revisions\/5910"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media\/5908"}],"wp:attachment":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media?parent=5890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/categories?post=5890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/tags?post=5890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}