<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Muhammet Yilmaz | Angular & Spring Boot]]></title><description><![CDATA[Muhammet Yilmaz | Angular & Spring Boot]]></description><link>https://muhammetyilmaz.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 18 Nov 2026 13:15:44 GMT</lastBuildDate><atom:link href="https://muhammetyilmaz.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How I added real RTL (Arabic) and three languages to an Angular + PrimeNG app]]></title><description><![CDATA[Typed translations, logical CSS, PrimeNG datepicker and paginator fixes, and keeping charts and numbers LTR in an Arabic Angular app.]]></description><link>https://muhammetyilmaz.hashnode.dev/how-i-added-real-rtl-arabic-and-three-languages-to-an-angular-primeng-app</link><guid isPermaLink="true">https://muhammetyilmaz.hashnode.dev/how-i-added-real-rtl-arabic-and-three-languages-to-an-angular-primeng-app</guid><category><![CDATA[Angular]]></category><category><![CDATA[TypeScript]]></category><category><![CDATA[webdev]]></category><category><![CDATA[CSS]]></category><dc:creator><![CDATA[MUHAMMET YILMAZ]]></dc:creator><pubDate>Mon, 16 Nov 2026 11:42:31 GMT</pubDate><content:encoded><![CDATA[<p>I'm building a hospital dashboard template with Angular 18 and PrimeNG 17, in English, Arabic and Turkish.
Adding <code>dir="rtl"</code> to <code>&lt;html&gt;</code> is about the first 10% of right-to-left support. Here is the rest, with the code I ended up using.</p>
<p>I did not use an i18n library for this. With around 200 keys and a runtime language switch, a small typed service was enough.
For a bigger app I would look at Transloco.</p>
<h2>1. A typed dictionary, so a missing translation breaks the build</h2>
<p>English is the master. The other languages must define every key:</p>
<pre><code class="language-ts">// en.ts
export const EN = { 'nav.patients': 'Patients' /* ... */ } as const;
export type Key = keyof typeof EN;
export type Dict = Record&lt;Key, string&gt;;

// ar.ts
export const AR: Dict = { 'nav.patients': 'المرضى' /* ... */ };
</code></pre>
<p>If I add a key to <code>en.ts</code> and forget Arabic, <code>ng build</code> fails. You cannot ship half a translation.
(Keys built at runtime, like <code>'ward.' + p.ward</code>, are plain strings, so those still need a test or a fallback.)</p>
<p>A pipe makes templates short:</p>
<pre><code class="language-ts">@Pipe({ name: 't', standalone: true, pure: false })
export class TranslatePipe implements PipeTransform {
  private readonly i18n = inject(I18nService);

  transform(key: string, params?: Record&lt;string, string | number&gt;): string {
    this.i18n.lang(); // read the signal so views refresh when the language changes
    return this.i18n.t(key, params);
  }
}
</code></pre>
<pre><code class="language-html">{{ 'nav.patients' | t }}
{{ 'appt.count' | t: { n: 3 } }}
</code></pre>
<h2>2. One effect keeps the page, PrimeNG and the direction in sync</h2>
<pre><code class="language-ts">effect(() =&gt; {
  const lang = this.lang();
  const root = document.documentElement;
  root.lang = lang;
  root.dir = lang === 'ar' ? 'rtl' : 'ltr';
  this.primeng.setTranslation(this.primeTranslation(lang));
});
</code></pre>
<p>PrimeNG needs its own texts (month names, weekdays, "no results"). I generate them with <code>Intl</code> instead of typing them:</p>
<pre><code class="language-ts">const days = (weekday: 'long' | 'short' | 'narrow') =&gt;
  Array.from({ length: 7 }, (_, i) =&gt;
    new Intl.DateTimeFormat(locale, { weekday }).format(new Date(2024, 0, 7 + i)));
</code></pre>
<p>(7 January 2024 is a Sunday, which is what PrimeNG expects at index 0.)
For Arabic I use the locale <code>ar-u-nu-latn</code>, which keeps Western digits. For clinical numbers that is what most hospital software does.</p>
<h2>3. Use logical CSS properties</h2>
<p>This is the change with the best return. Replace <code>left</code> and <code>right</code> with their logical versions and most of the layout flips by itself:</p>
<pre><code class="language-scss">.side  { border-inline-end: 1px solid var(--surface-border); }
.tile  { border-inline-start: 4px solid var(--sev); }
.unit  { margin-inline-start: .25rem; }
.badge { inset-inline-end: 1rem; }
</code></pre>
<p>A CSS grid sidebar also moves to the correct side without any extra code once <code>dir</code> is <code>rtl</code>.</p>
<h2>4. The leftovers: what PrimeNG does not flip</h2>
<p>This is where the time went. In my case:</p>
<pre><code class="language-scss">[dir='rtl'] {
  /* arrows are SVG icons in PrimeNG 17, not pi-* classes */
  .p-datepicker-prev .p-icon, .p-datepicker-next .p-icon,
  .p-paginator-prev .p-icon, .p-paginator-next .p-icon { transform: scaleX(-1); }

  /* table text alignment and sort icon spacing */
  .p-datatable .p-datatable-thead &gt; tr &gt; th,
  .p-datatable .p-datatable-tbody &gt; tr &gt; td { text-align: right; }

  /* search input with an icon */
  .p-input-icon-left &gt; i:first-of-type { left: auto; right: .75rem; }
  .p-input-icon-left &gt; .p-inputtext { padding-left: .75rem; padding-right: 2.5rem; }
}
</code></pre>
<p>My first attempt flipped <code>.pi-chevron-left</code>, and nothing changed. A screenshot showed the calendar's previous button pointing the wrong way. Always check with real screenshots.</p>
<h2>5. Things that should stay left-to-right</h2>
<ul>
<li><strong>Charts.</strong> Time runs left to right in a clinical chart, even in an Arabic UI. I wrap the chart: <code>&lt;div dir="ltr"&gt;&lt;p-chart ... /&gt;&lt;/div&gt;</code>.</li>
<li><strong>Values with units.</strong> <code>4–11 ×10³/µL</code> gets scrambled in an RTL paragraph. Wrap it: <code>&lt;bdi dir="ltr"&gt;4–11 ×10³/µL&lt;/bdi&gt;</code>.</li>
<li><strong>Usernames and passwords.</strong> Give those inputs <code>dir="ltr"</code>.</li>
<li><strong>Directional icons</strong>, like a "back" arrow, need flipping. Plain icons, like a bell, do not.</li>
</ul>
<h2>My checklist before calling it done</h2>
<ul>
<li>Dialogs and dropdown overlays (they are appended to <code>&lt;body&gt;</code>, so check them separately)</li>
<li>Calendar header arrows and week start (Saturday for Arabic, Monday for Turkish)</li>
<li>Table headers, sort icons and the paginator</li>
<li>Mixed text and numbers in the same line</li>
<li>Mobile: the bottom navigation bar in RTL</li>
</ul>
<h2>Try it</h2>
<p>The result is running here, with a language switch at the top: <a href="https://careboard-pro.vercel.app">https://careboard-pro.vercel.app</a> (login: <code>doctor</code> / <code>doctor123</code>).</p>
<p>Disclosure: this comes from a hospital dashboard template I sell (Angular + Spring Boot, three languages with full RTL): <a href="https://buy.polar.sh/polar_cl_GfjpPuUI9MVVh75FlpOwUqCb14Sh3T9xjoRkt40qfZG">https://buy.polar.sh/polar_cl_GfjpPuUI9MVVh75FlpOwUqCb14Sh3T9xjoRkt40qfZG</a>
If you have questions about any part of the RTL work, ask in the comments.</p>
]]></content:encoded></item></channel></rss>