https://github.com/tanmayshil/next-language-translate
A modern multilingual product landing page built with Next.js 15, TypeScript, Tailwind CSS, shadcn/ui, Magic UI, React Query, and i18next. Supports English, Hindi, and Bengali translations for both static UI text and dynamic FakeStore API product data using google-translate-api-x.
https://github.com/tanmayshil/next-language-translate
fakestoreapi google-translate-api i18n-react i18next internationalization language-switcher magicui multilingual nextjs shadcn-ui tailwindcss typescript
Last synced: 17 days ago
JSON representation
A modern multilingual product landing page built with Next.js 15, TypeScript, Tailwind CSS, shadcn/ui, Magic UI, React Query, and i18next. Supports English, Hindi, and Bengali translations for both static UI text and dynamic FakeStore API product data using google-translate-api-x.
- Host: GitHub
- URL: https://github.com/tanmayshil/next-language-translate
- Owner: TanmayShil
- Created: 2026-05-27T06:06:09.000Z (about 2 months ago)
- Default Branch: master
- Last Pushed: 2026-05-27T07:26:30.000Z (about 2 months ago)
- Last Synced: 2026-05-27T08:25:53.820Z (about 2 months ago)
- Topics: fakestoreapi, google-translate-api, i18n-react, i18next, internationalization, language-switcher, magicui, multilingual, nextjs, shadcn-ui, tailwindcss, typescript
- Language: TypeScript
- Homepage: https://next-language-translate.vercel.app
- Size: 315 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Agents: AGENTS.md
Awesome Lists containing this project
README
### Next.js Language Translator Store ๐
A modern multilingual product landing page built with Next.js 15, TypeScript, Tailwind CSS, shadcn/ui, Magic UI, React Query, and i18next.
The application supports dynamic language translation for both static UI text and API product data using google-translate-api-x.
### ๐ Features
---
### ๐ Multi-language support
- English
- Hindi
- Bengali
### ๐จ Modern UI using:
- Tailwind CSS
- shadcn/ui
- Magic UI
### ๐ฆ Product listing using FakeStore API
### ๐ Dynamic product translation
- Product title
- Description
- Category
### โก React Query caching
### ๐ Language auto-detection using:
- i18next-browser-languagedetector
### ๐ง Custom translation hooks
---
### ๐ Tech Stack
| Technology | Purpose |
| ---------------------- | ----------------------- |
| Next.js | React Framework |
| TypeScript | Type Safety |
| Tailwind CSS | Styling |
| shadcn/ui | UI Components |
| Magic UI | Animation/UI Effects |
| i18next | Internationalization |
| React Query | API State Management |
| FakeStore API | Product Data |
| google-translate-api-x | Dynamic Translation API |
---
### ๐ Project Structure
```
โโโ ๐ public/
โ โโโ ๐ผ๏ธ file.svg
โ โโโ ๐ผ๏ธ globe.svg
โ โโโ ๐ผ๏ธ next.svg
โ โโโ ๐ผ๏ธ vercel.svg
โ โโโ ๐ผ๏ธ window.svg
โโโ ๐ src/
โ โโโ ๐ @type/
โ โ โโโ ๐ product.ts
โ โโโ ๐ JSON/
โ โ โโโ ๐ data/
โ โ โ โโโ ๐ about.ts
โ โ โ โโโ ๐ contact.ts
โ โ โโโ ๐ lottie/
โ โโโ ๐ api/
โ โ โโโ ๐ api.function.ts
โ โ โโโ ๐ axios.instance.ts
โ โโโ ๐ app/
โ โ โโโ ๐ (userpannel)/
โ โ โ โโโ ๐ layout.tsx
โ โ โ โโโ ๐ page.tsx
โ โ โโโ ๐ api/
โ โ โ โโโ ๐ translate/
โ โ โ โโโ ๐ route.ts
โ โ โโโ ๐ favicon.ico
โ โ โโโ ๐จ globals.css
โ โ โโโ ๐ layout.tsx
โ โ โโโ ๐ providers.tsx
โ โโโ ๐ assets/
โ โ โโโ ๐ json/
โ โ โ โโโ โ๏ธ about.json
โ โ โโโ ๐ผ๏ธ banner1.jpg
โ โ โโโ ๐ผ๏ธ banner2.jpg
โ โ โโโ ๐ผ๏ธ banner3.jpg
โ โโโ ๐ components/
โ โ โโโ ๐ ui/
โ โ โ โโโ ๐ badge.tsx
โ โ โ โโโ ๐ border-beam.tsx
โ โ โ โโโ ๐ button.tsx
โ โ โ โโโ ๐ card.tsx
โ โ โ โโโ ๐ input.tsx
โ โ โ โโโ ๐ lens.tsx
โ โ โ โโโ ๐ magic-card.tsx
โ โ โ โโโ ๐ morphing-text.tsx
โ โ โ โโโ ๐ scroll-area.tsx
โ โ โ โโโ ๐ select.tsx
โ โ โ โโโ ๐ separator.tsx
โ โ โ โโโ ๐ shimmer-button.tsx
โ โ โ โโโ ๐ sparkles-text.tsx
โ โ โ โโโ ๐ textarea.tsx
โ โ โ โโโ ๐ tooltip.tsx
โ โ โโโ ๐ LanguageSwitcher.tsx
โ โ โโโ ๐ ProductCard.tsx
โ โ โโโ ๐ ProductSkleton.tsx
โ โ โโโ ๐ ThemeToggle.tsx
โ โโโ ๐ hook/
โ โ โโโ ๐ useProducts.ts
โ โ โโโ ๐ useTranslate.ts
โ โโโ ๐ i18n/
โ โ โโโ ๐ locales/
โ โ โ โโโ โ๏ธ bn.json
โ โ โ โโโ โ๏ธ en.json
โ โ โ โโโ โ๏ธ hi.json
โ โ โโโ ๐ index.ts
โ โโโ ๐ layout/
โ โ โโโ ๐ Footer.tsx
โ โ โโโ ๐ Navbar.tsx
โ โโโ ๐ lib/
โ โ โโโ ๐ utils.ts
โ โโโ ๐ section/
โ โโโ ๐ About.tsx
โ โโโ ๐ Banner.tsx
โ โโโ ๐ Contact.tsx
โ โโโ ๐ Products.tsx
โโโ โ๏ธ .gitignore
โโโ ๐ AGENTS.md
โโโ ๐ CLAUDE.md
โโโ ๐ README.md
โโโ โ๏ธ components.json
โโโ ๐ eslint.config.mjs
โโโ ๐ next.config.ts
โโโ โ๏ธ package-lock.json
โโโ โ๏ธ package.json
โโโ ๐ postcss.config.mjs
โโโ โ๏ธ tsconfig.json
```
---
### ๐ Step 1 โ Install Dependencies
```
npm install i18next react-i18next i18next-browser-languagedetector
npm install @tanstack/react-query
npm install google-translate-api-x
npx shadcn@latest init
```
---
### ๐ Step 2 โ Configure i18next
---
## What is i18next? ๐
i18next is an internationalization library used for translating static UI text.
Example:
```
t("About Us")
```
Depending on selected language:
| Language | Output |
| -------- | --------------- |
| English | About Us |
| Hindi | เคนเคฎเคพเคฐเฅ เคฌเคพเคฐเฅ เคฎเฅเค |
| Bengali | เฆเฆฎเฆพเฆฆเงเฆฐ เฆธเฆฎเงเฆชเฆฐเงเฆเง |
---
## Why Use i18next?
Because:
- Easy translation management
- Multi-language support
- Automatic language detection
- Reusable translation keys
- Supports React perfectly
---
## i18n Configuration
```
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import en from "@/locales/en/common.json";
import hi from "@/locales/hi/common.json";
import bn from "@/locales/bn/common.json";
i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
resources: {
en: {
translation: en,
},
hi: {
translation: hi,
},
bn: {
translation: bn,
},
},
fallbackLng: "en",
interpolation: {
escapeValue: false,
},
});
export default i18n;
```
---
### ๐ Step 3 โ Translation JSON Files
## locales/en/common.json
```
{
"About Us": "About Us",
"Contact": "Contact",
"Add To Cart": "Add To Cart"
}
```
## locales/hi/common.json
```
{
"About Us": "เคนเคฎเคพเคฐเฅ เคฌเคพเคฐเฅ เคฎเฅเค",
"Contact": "เคธเคเคชเคฐเฅเค เคเคฐเฅเค",
"Add To Cart": "เคเคพเคฐเฅเค เคฎเฅเค เคเฅเคกเคผเฅเค"
}
```
## locales/bn/common.json
```
{
"About Us": "เฆเฆฎเฆพเฆฆเงเฆฐ เฆธเฆฎเงเฆชเฆฐเงเฆเง",
"Contact": "เฆฏเงเฆเฆพเฆฏเงเฆ",
"Add To Cart": "เฆเฆพเฆฐเงเฆเง เฆฏเงเฆ เฆเฆฐเงเฆจ"
}
```
---
### ๐ Step 4 โ Why Static Translation Is Not Enough?
i18next works perfectly for static text.
But API product data comes dynamically:
```
title
description
category
```
These values are not stored in JSON files.
So we need:
โ
Backend Translation API
---
### ๐ Step 5 โ Create Translation API Route
## Why API Route?
Because:
- Dynamic product data changes
- We cannot manually store all translations
- API translates text in real-time
## app/api/translate/route.ts
```
import { NextRequest, NextResponse } from "next/server";
import translate from "google-translate-api-x";
import {
RequestBody,
TranslationResponse,
} from "@/@type/product";
export async function POST(
req: NextRequest,
): Promise> {
let body: RequestBody | null = null;
try {
body = await req.json();
const result = await translate(body?.text || "", {
to: body?.target || "",
});
return NextResponse.json({
translatedText: result.text,
});
} catch (error) {
console.log(error);
return NextResponse.json(
{
translatedText: body?.text || "",
},
{
status: 500,
},
);
}
}
```
---
### ๐ Step 6 โ Why google-translate-api-x?
This package helps:
- Translate dynamic text
- No Google Cloud billing setup
- Easy integration
- Supports many languages
---
### ๐ Step 7 โ Create Translation Function
## api/api.function.ts
```
export const translateTextFns = async (
text: string,
target: string,
) => {
const response = await axios.post("/api/translate", {
text,
target,
});
return response.data.translatedText;
};
```
---
### ๐ Step 8 โ Why TanStack Query?
Without TanStack Query:
- Multiple API calls happen
- Performance becomes slow
TanStack Query:
- โ
Caches translations
- โ
Avoids duplicate requests
- โ
Improves performance
---
### ๐ Step 9 โ Final Workflow
```
User changes language
โ
i18next updates static text
โ
React Query detects language change
โ
Translation hooks call API
โ
API translates product data
โ
UI updates dynamically
```
---
## ๐โโ๏ธ Author
Made with โค๏ธ by Tanmay Shil
GitHub: [@TanmayShil](https://github.com/TanmayShil)