Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 11, 2025

Adds comprehensive Bengali (বাংলা) localization for Bangladesh market where 85% of users prefer Bengali UI and UTF-16 SMS encoding is required.

Core Infrastructure

  • next-intl integration: Locale routing middleware, 529 translation keys per locale (en/bn), automatic detection from browser/cookie/URL
  • Database models: ProductTranslation and CategoryTranslation with unique constraints on [id, locale]
  • Translation API: Full CRUD endpoints at /api/products/[id]/translations and /api/categories/[id]/translations with Zod validation

Number Formatting & Cultural Adaptations

import { formatBengaliCurrency, toBengaliNumerals } from '@/lib/utils/bengali-numbers';

formatBengaliCurrency(1234.50, { useBengaliNumerals: true }); // "৳১,২৩৪.৫০"
toBengaliNumerals(12345); // "১২৩৪৫"
  • Bengali numerals (০-৯), currency (৳), dates (২৫ নভেম্বর ২০২৫), phone numbers (+৮৮০১৮১২-৩৪৫৬৭৮)
  • Time-based greetings (সুপ্রভাত/শুভ সন্ধ্যা), formal address (আপনি)

SMS Encoding (UTF-16)

import { calculateSMSCost } from '@/lib/utils/sms-counter';

const bengaliText = 'আপনার অর্ডার নিশ্চিত হয়েছে।';
const calc = calculateSMSCost(bengaliText);
// { encoding: 'UTF-16', charCount: 29, maxCharsPerSMS: 70, smsCount: 1, costBDT: 1.0 }
  • Automatic UTF-16 detection for Bengali (70 chars/SMS vs 160 for GSM-7)
  • Multi-part splitting at 67 chars/part
  • Cost calculator (৳1.00 per SMS)

Translation Service Layer

import { getProductTranslation, bulkImportProductTranslations } from '@/lib/services/translation.service';

// Get product with locale-specific translation, fallback to English
const product = await getProductTranslation(productId, 'bn');

// Bulk import from CSV
await bulkImportProductTranslations([
  { productId: 'abc', locale: 'bn', name: 'স্মার্টফোন', description: '...' }
]);

UI Components

  • LanguageSwitcher: Dropdown with 🇧🇩 বাংলা / 🇺🇸 English, persists to cookie
  • Demo page at /i18n-demo: Interactive showcase of all formatting utilities

Files Added

src/
  i18n.ts                              # next-intl config
  messages/en.json, bn.json            # 529 keys each
  lib/utils/bengali-numbers.ts         # Number formatting (213 lines)
  lib/utils/sms-counter.ts             # SMS encoding (246 lines)
  lib/services/translation.service.ts  # Translation helpers (346 lines)
  components/language-switcher.tsx     # Language toggle
  app/i18n-demo/page.tsx              # Interactive demo
  app/api/products/[id]/translations/  # Product translation CRUD
  app/api/categories/[id]/translations/# Category translation CRUD
middleware.ts                          # Locale routing
prisma/schema.prisma                   # +ProductTranslation, +CategoryTranslation
docs/BENGALI_LOCALIZATION.md          # 10k+ word guide

Migration Required

npm run prisma:migrate:dev  # Adds ProductTranslation, CategoryTranslation tables

Default locale is Bengali (bn). English routes prefixed with /en/*.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Phase 1.5] Bengali Localization Infrastructure</issue_title>
<issue_description>## Priority: P1
Phase: 1.5
Parent Epic: #28 (Bangladesh Payment Methods)
Estimate: 2 days
Type: Story

Overview

Implement comprehensive Bengali language support (বাংলা) for the entire storefront, admin dashboard, and customer communications. Bangladesh has 170+ million Bengali speakers, and 85% of e-commerce customers prefer Bengali interfaces. This feature uses next-intl for internationalization with proper UTF-16 encoding for SMS, Bengali number formatting, and seasonal templates.

Context

Bengali localization is essential for Bangladesh market:

  • Language Preference: 85% prefer Bengali UI (2024 survey)
  • Mobile Users: 90% use Bengali keyboard on smartphones
  • SMS Encoding: UTF-16 required (70 chars vs 160 for English)
  • Number Format: Bengali numerals (০১২৩৪৫৬৭৮৯) vs Western (0123456789)
  • Cultural Dates: Bengali calendar for festivals (Pohela Boishakh, Eid)
  • Search: Requires phonetic search (বিশ্ব = bishho = world)

Acceptance Criteria

  1. next-intl Setup

    • ✅ Install and configure next-intl package
    • ✅ Locale routing: /en/... and /bn/... paths
    • ✅ Middleware for locale detection (browser, cookie, URL)
    • ✅ Default locale: Bengali (bn) for .bd domains
  2. Translation Files

    • ✅ English (en.json): 500+ keys for all UI elements
    • ✅ Bengali (bn.json): 500+ keys with proper translations
    • ✅ Nested structure: common, auth, product, cart, checkout, dashboard
    • ✅ Pluralization rules: "1 পণ্য" vs "৫ টি পণ্য"
  3. Database Translations

    • ✅ ProductTranslation model (productId, locale, name, description)
    • ✅ CategoryTranslation model (categoryId, locale, name)
    • ✅ API endpoints return translations based on Accept-Language header
    • ✅ Admin can add translations for products/categories
  4. Number Formatting

    • ✅ Bengali numerals option: ১২৩৪.৫০ (locale-aware)
    • ✅ Currency display: ৳১,২৩৪.৫০ or Tk 1,234.50
    • ✅ Date formatting: ২৫ নভেম্বর ২০২৫ (Bengali date)
    • ✅ Phone numbers: +৮৮০১৮১২-৩৪৫৬৭৮
  5. SMS Encoding

    • ✅ UTF-16 encoding for Bengali text (70 chars/SMS vs 160)
    • ✅ Character counter shows remaining chars correctly
    • ✅ Automatic multi-part SMS splitting
    • ✅ Cost calculator (৳1.00 per 70 chars vs ৳1.00 per 160 English)
  6. Email Templates

    • ✅ Order confirmation: Bengali + English bilingual
    • ✅ Shipping notification: Bengali subject + body
    • ✅ Payment receipt: Amounts in Bengali numerals option
    • ✅ Customer support: Bengali reply templates
  7. Storefront UI

    • ✅ Language switcher in header (বাংলা / English toggle)
    • ✅ Product names, descriptions, categories in Bengali
    • ✅ Search supports Bengali input (কম্পিউটার, মোবাইল, জুতা)
    • ✅ Filter labels: "দাম", "ব্র্যান্ড", "রঙ"
    • ✅ Cart/Checkout: Full Bengali workflow
  8. Admin Dashboard

    • ✅ Translation management UI
    • ✅ Bulk translation import (CSV with en/bn columns)
    • ✅ Missing translation warnings
    • ✅ Google Translate API integration (optional, auto-suggest)
  9. Cultural Adaptations

    • ✅ Bengali calendar dates for seasonal sales (পহেলা বৈশাখ, ঈদ)
    • ✅ Greeting based on time: "সুপ্রভাত" (morning), "শুভ সন্ধ্যা" (evening)
    • ✅ Formal vs informal address (আপনি vs তুমি - use formal)
    • ✅ Right-to-left text support for Arabic (Eid wishes)
  10. SEO & Metadata

    • ✅ Bengali meta titles: <title>পণ্যের নাম | দোকানের নাম</title>
    • ✅ Bengali meta descriptions (150-160 chars)
    • ✅ hreflang tags: <link rel="alternate" hreflang="bn" href="/bn/..." />
    • ✅ Open Graph tags with Bengali content

Technical Implementation

1. next-intl Configuration

// next.config.ts
import createNextIntlPlugin from 'next-intl/plugin';

const withNextIntl = createNextIntlPlugin('./src/i18n.ts');

/** @type {import('next').NextConfig} */
const nextConfig = {
  // ... existing config
};

export default withNextIntl(nextConfig);
// src/i18n.ts
import { getRequestConfig } from 'next-intl/server';
import { notFound } from 'next/navigation';

// Supported locales
export const locales = ['en', 'bn'] as const;
export type Locale = (typeof locales)[number];

export default getRequestConfig(async ({ locale }) => {
  // Validate locale
  if (!locales.includes(locale as Locale)) notFound();

  return {
    messages: (await import(`./messages/${locale}.json`)).default,
    timeZone: 'Asia/Dhaka',
    now: new Date(),
  };
});
// src/middleware.ts
import createMiddleware from 'next-intl/middleware';
import { locales } from './i18n';

export default createMiddleware({
  locales,
  defaultLocale: 'bn', // Bengali default for Bangladesh
  localePrefix: 'as-needed', // Only show /en for English, hide /bn for Bengali
  localeDetection: true, // Auto...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes CodeStorm-Hub/stormcomui#31

<!-- START COPILOT CODING AGENT TIPS -->
---

 Let Copilot coding agent [set things up for you](https://github.com/CodeStorm-Hub/stormcomui/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link

vercel bot commented Dec 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
stormcomui Error Error Dec 11, 2025 6:37pm

…ies, and schema updates

Co-authored-by: rafiqul4 <124497017+rafiqul4@users.noreply.github.com>
Copilot AI and others added 2 commits December 11, 2025 18:22
Co-authored-by: rafiqul4 <124497017+rafiqul4@users.noreply.github.com>
Co-authored-by: rafiqul4 <124497017+rafiqul4@users.noreply.github.com>
Comment on lines +19 to +24
import {
calculateSMSCost,
detectSMSEncoding,
getSMSEncodingInfo,
splitSMS,
} from '@/lib/utils/sms-counter';
Co-authored-by: rafiqul4 <124497017+rafiqul4@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Bengali localization for storefront and admin dashboard Implement Bengali localization infrastructure with i18n, SMS encoding, and translation management Dec 11, 2025
Copilot AI requested a review from rafiqul4 December 11, 2025 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants