Skip to content

feat: add Arabic-first i18n with locale switcher#21

Open
abdelrhmanehab10 wants to merge 4 commits intoBLEU-IO:masterfrom
abdelrhmanehab10:feat/i18n-arabic-interface
Open

feat: add Arabic-first i18n with locale switcher#21
abdelrhmanehab10 wants to merge 4 commits intoBLEU-IO:masterfrom
abdelrhmanehab10:feat/i18n-arabic-interface

Conversation

@abdelrhmanehab10
Copy link
Copy Markdown

Summary

Closes #17

This PR adds an Arabic-first internationalization flow for the BLEU website.

What changed

  • added Arabic-first routing:
    • / for Arabic
    • /en/ for English
  • added a language switcher in the navbar
  • translated shared UI copy to Arabic and English
  • generated localized versions of shared pages and blog post routes
  • added RTL support for Arabic UI
  • kept authored blog content unchanged
  • forced post metadata and tags to render LTR for readability on Arabic post pages
  • updated contribute links to point to the localized contributing page instead of GitHub
  • added build-time translation validation and localized build verification

Technical notes

  • uses i18next with split JSON translation files
  • uses shared Eleventy templates for both locales
  • validates translation key parity during build
  • verifies localized output routes during build

How to test

  1. Run npm install
  2. Run npm run build
  3. Run npm run dev
  4. Verify these routes:
    • /
    • /en/
    • /blogs/
    • /en/blogs/
  5. Verify the language switcher maps between equivalent pages
  6. Verify blog cards appear in both Arabic and English listing pages
  7. Verify Arabic pages use RTL UI
  8. Verify blog post metadata and tags remain LTR on Arabic post pages
  9. Verify contribute links open the localized contributing

Scope notes

  • shared UI is translated
  • authored blog content, titles, excerpts, and tags remain as-authored
  • third-party widget UI is only localized where supported

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an Arabic-first internationalization setup for the Eleventy site, with / serving Arabic and /en/ serving English, plus shared translated UI and RTL support.

Changes:

  • Added i18next-based build-time i18n loading + translation parity validation, with per-locale page generation via Eleventy pagination.
  • Updated templates (home, blogs, contributing, layout/components) to use translation keys and locale-aware URLs.
  • Added RTL/LTR styling adjustments, a navbar language switcher, and build verification scripts to ensure localized outputs exist.

Reviewed changes

Copilot reviewed 34 out of 35 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
.eleventy.js Initializes i18n globals (t, localeUrl) and validates dictionaries during build.
src/i18n/index.js Loads translation resources, validates parity, and localizes URLs.
src/_data/locales.js Defines supported locales and routing prefixes.
src/index.njk + src/index.11tydata.js Converts home page to localized metadata + localized routing.
src/blogs.njk + src/blogs.11tydata.js Converts blogs listing page to localized metadata + localized routing.
content/blogs/blogs.11tydata.js Generates localized blog post routes for both locales.
src/contributing.njk + src/contributing.11tydata.js Localizes the contributing page and routes.
src/_includes/layouts/base.njk Adds locale-aware <html lang/dir>, localized meta, and hreflang alternates.
src/_includes/layouts/blog.njk Localizes blog UI strings and improves RTL/LTR handling for metadata/tags.
src/_includes/components/* Localizes header/footer/widget/giscus and adds a language switcher.
src/assets/css/input.css Adds RTL support, bidi handling, and language switcher styling; adds Arabic/Latin fonts.
src/assets/js/main.js Adds language switcher navigation + stores locale; keeps tag filtering enhancement.
scripts/check-i18n.js + scripts/verify-localized-build.js Adds translation validation and localized output verification during build.
package.json + package-lock.json Adds i18next dependency and build steps for i18n validation/verification.
src/_data/site.json Removes hardcoded tagline/description in favor of translated equivalents.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

permalink: /blogs/
---

{% set posts = collections.blogs %}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as the home page: iterating over collections.blogs will likely render each blog post twice (Arabic + English generated pages). Filter the collection by post.data.locale === locale (or create per-locale collections) so /blogs/ and /en/blogs/ show a single set of posts.

Suggested change
{% set posts = collections.blogs %}
{% set posts = (collections.blogs or []) | selectattr("data.locale", "equalto", locale) | list %}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I validated this one as well, and it does not reproduce with the current Eleventy setup.
collections.blogs is built from the source markdown files in .eleventy.js, so it is not currently doubled by localized output generation. I verified the generated listing pages and both of these render a single set of posts:

  • _site/blogs/index.html → 3 cards
  • _site/en/blogs/index.html → 3 cards

So /blogs/ and /en/blogs/ are not rendering duplicate posts in the current implementation. Because of that, I’m not applying the suggested locale filter here.

<a
href="https://github.com/{{ site.repo }}/edit/main/content/blogs/{{ page.fileSlug }}.md"
<a
href="https://github.com/{{ site.repo }}/edit/master/content/blogs/{{ page.fileSlug }}.md"
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The “Edit on GitHub” link switched from /edit/main/... to /edit/master/.... If the repository default branch is main (as previously assumed), this link will 404. Consider reverting to main or making the branch configurable (e.g., site.defaultBranch).

Suggested change
href="https://github.com/{{ site.repo }}/edit/master/content/blogs/{{ page.fileSlug }}.md"
href="https://github.com/{{ site.repo }}/edit/main/content/blogs/{{ page.fileSlug }}.md"

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I validated this against the local git metadata, and master is the current default branch in this repository context.

Local refs show:

  • remotes/origin/HEAD -> origin/master
  • remotes/origin/master
  • remotes/upstream/master

So switching the edit link to master was intentional and matches the branch this repo is currently using. Because of that, I’m not reverting this to main.

Copy link
Copy Markdown
Member

@fahdfady fahdfady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice work overall. And the font is really cool!
I just had some comments on the translation itself. We can work on this together and get this merged.

"title": "انضم إلى ديسكورد الخاص بنا",
"members": "عضو",
"online": "متصل الآن",
"joinServer": "انضم إلى الخادم"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

كلمة "سيرفر" منطقية أكتر من "الخادم" .. على الأقل في السياق الحالي .. كلمة خادم لا تستخدم إطلاقا على حد احتكاكي.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

تمام عملتها دي

"description": "منصة BLEU المجتمعية لمشاركة المعرفة، والتعلّم، وبناء مستقبل التقنية معًا."
},
"hero": {
"title": "نبني ونتعلّم ونستكشف ونتّحد",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ترجمة ممتازة
حقيقي ممكن اكون أمضيت بعض الوقت في محاولة لترجمة BLEU
هل في إمكانية نضيف بخط صغير تحتها الجملة الأصلية بالإنجليزية؟
Building Learning Exploring Uniting
لو في إمكانية تمام. لو شعرت إن التعديل ده خارج حدود الـ PR
ممكن نتخطاه ونركز في الباقي

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

تمام عملتها برده

"description": "انسخ المستودع وأضف ملف Markdown الخاص بك داخل content/blogs/."
},
"pr": {
"title": "افتح طلب سحب",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

كلمة "طلب سحب" غريبة جدا بالنسبة لي. لا أستطيع في التفكير لمقابل ليها بالعربية لكن أنا مستنكر جدا الجملة دي. محتاجين نفكر لها في بديل. عندك فكرة تانية؟

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ممكن نسيب PR بالأنجليزي تبقي افتح PR اي رأيك؟

"description": "أرسل طلب السحب الخاص بك. سيقوم المجتمع بمراجعته وتقديم الملاحظات."
},
"publish": {
"title": "الدمج = النشر",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

وكذلك مع كلمة دمج. مع إنها ترجمة جيدة لـ Merge
ولكنها في وجهة نظري ترجمة حرفية .. ممكن نشتغل عليها أكتر في ظني ونطلع بحاجة دقيقة أكتر

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ممكن نبدلها بالنشر بما انها بتنشر المقالة؟

@@ -0,0 +1,29 @@
{
"site": {
"communityLabel": "المجتمع",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

من المفترض تتتكتب "مجتمع" بدون ألف ولام التعريف
لأنها في السياق الكامل "مجتمع بلو" وليس "المجتمع بلو"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

تمام

"label": "التصفية حسب الوسم:"
},
"empty": {
"title": "لا توجد مقالات منشورة بعد.",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"مدونات" وليس مقالات"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

غيرتها فالويبسايت كله

"submitViaPr": "أرسل مقالة عبر طلب سحب"
},
"filter": {
"label": "التصفية حسب الوسم:"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

محتاجين نشتغل برضو على كلمة "الوسم"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

تصنيف حلوه؟

"guideline3": "Include code examples where helpful",
"guideline4": "Use clear, descriptive titles",
"guideline5": "Add a thumbnail image if possible (16:9 ratio recommended)",
"guideline6": "Images should be added to /src/assets/images/",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code block for /src/assets/images/

"guideline3": "أضف أمثلة برمجية عند الحاجة",
"guideline4": "استخدم عناوين واضحة ومعبرة",
"guideline5": "أضف صورة مصغرة إن أمكن (يُفضّل نسبة 16:9)",
"guideline6": "أضف الصور داخل /src/assets/images/",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code block for /src/assets/images/

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

عملتها دي برده

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

i18n: Arabic interface for the website

3 participants