Skip to content

Commit 7b9a7d0

Browse files
Maulik176coderabbitai[bot]sumitsaurabh927
authored
feat: add global-onboard demo app (closes #1761) (#1890)
* Add GlobalOnboard demo app to /community * chore: add changeset for community submission * fix(global-onboard): harden export and task edits * fix(global-onboard): prevent stale translations and update docs * Update community/global-onboard/app/page.tsx this are just some CSS changes i dont know what it has to do with PR quality Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix(global-onboard): tighten api guards and cleanup * fix(global-onboard): harden translation errors * fix(global-onboard): harden api and align tailwind v4 * fix(global-onboard): improve tooling and translations * fix(global-onboard): defer download url cleanup * chore(global-onboard): remove theme switching * chore: replace changeset with empty --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Sumit Saurabh <62152915+sumitsaurabh927@users.noreply.github.com>
1 parent e3e36ec commit 7b9a7d0

40 files changed

+18705
-0
lines changed

.changeset/thin-dryers-boil.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

community/global-onboard/README.md

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# GlobalOnboard · LingoHack25 ✨
2+
3+
4+
**One onboarding checklist. Any language. Fully Configurable**
5+
HR writes once in English, and GlobalOnboard turns it into a polished, localized employee experience by combining **Lingo CLI**, **Lingo JavaScript SDK**, and **Lingo CI**.
6+
7+
8+
## 🧠 The MAIN Pillars of GlobalOnboard
9+
10+
- **Real personas:** HR Workspace (authoring) + Employee Experience (preview) wired together in real time.
11+
- **Full Lingo toolchain:** Static JSON via CLI, runtime personalization via SDK, and CI automation so translations stay fresh.
12+
- **Enterprise-ready touches:** Translation QA mode, localization health warnings, onboarding pack export, and translation spinners that prove we’re production aware.
13+
14+
### 🏅 Lingo Product Scorecard
15+
16+
| Lingo product | How GlobalOnboard uses it | Why it matters |
17+
| --- | --- | --- |
18+
| **Lingo CLI** | Generates `data/ui.{locale}.json` and `data/onboarding_template.{locale}.json` from English sources via `npx lingo.dev@latest run`. | Demonstrates the official static localization workflow. |
19+
| **Lingo JavaScript SDK** | Translates the welcome note and every custom task at runtime with caching, spinners, and graceful fallbacks. | Shows dynamic personalization for each employee preview. |
20+
| **Lingo CI** | `.github/workflows/i18n.yml` runs `npx lingo.dev@latest ci --pull-request` whenever English JSON or `i18n.json` changes. | Proves translation automation and GitHub integration end-to-end. |
21+
22+
---
23+
24+
## 🔑 Feature Highlights
25+
26+
| Area | What it unlocks | Lingo capability |
27+
| --- | --- | --- |
28+
| HR Workspace | Edit company, role, welcome note, and a fully dynamic checklist (add/delete/modify tasks). | Authoring surface for English source |
29+
| Employee Experience | Switch between `en`, `es`, `fr`, `hi` previews with live updates + translation loading overlay. | CLI JSON + SDK runtime translations |
30+
| Preview Modes | `Employee view` or `Translation QA` (side-by-side EN vs target locale) with Machine → Edited → Approved overrides. | Human-in-the-loop QA |
31+
| Localization Health | Warns when translated copy is >1.5× English length, per task + summary. | QA signal |
32+
| Onboarding Pack Export | One click generates a `.doc` bundle for the current locale (company, role, tasks, welcome note). | HR enablement |
33+
| Lingo CI Workflow | GitHub Action auto-runs `lingo.dev ci` whenever English JSON changes. | Translation automation |
34+
35+
---
36+
37+
## 🧩 Architecture At-a-Glance
38+
39+
```text
40+
HR inputs ──▶ English JSON templates ──▶ Lingo CLI generates data/ui.{locale}.json
41+
│ │
42+
│ └─▶ Lingo CI keeps translations up to date
43+
44+
├─▶ React state + localStorage overrides
45+
46+
└─▶ Lingo JS SDK
47+
├─ Welcome note runtime translation
48+
└─ Custom task translations (per locale) + caching
49+
```
50+
51+
---
52+
53+
## 🧪 Getting Started (Local Dev)
54+
55+
```bash
56+
git clone https://github.com/lingodotdev/lingo.dev.git
57+
cd lingo.dev/community/global-onboard
58+
npm install
59+
60+
# Provide your API key so CLI + SDK can translate
61+
export LINGO_DOT_DEV_API_KEY="your-key"
62+
# Optional alias used by some shells/CLIs
63+
export LINGODOTDEV_API_KEY="$LINGO_DOT_DEV_API_KEY"
64+
65+
npm run dev
66+
```
67+
68+
Visit **<http://localhost:3000>** — left panel is HR Workspace, right panel is the localized Employee preview.
69+
70+
---
71+
72+
## 🌐 Localization Workflow Cheat Sheet
73+
74+
### 1. Static JSON (Lingo CLI)
75+
- Source files: `data/ui.en.json`, `data/onboarding_template.en.json`
76+
- Configure targets in `i18n.json`
77+
- Generate translations:
78+
```bash
79+
export LINGO_DOT_DEV_API_KEY="your-key"
80+
npx lingo.dev@latest run
81+
```
82+
- CI automation: `.github/workflows/i18n.yml` runs `npx lingo.dev@latest ci --pull-request` on every push to `main` touching English JSON or `i18n.json`.
83+
84+
### 2. Runtime Personalization (Lingo JS SDK)
85+
- Welcome note + any **custom tasks** run through `lib/lingo-client.ts`.
86+
- We cache translations per locale, show a loading spinner overlay, and gracefully fall back to English if the SDK errors.
87+
88+
### 3. Translation QA Mode
89+
- Side-by-side English vs target locale.
90+
- Inline editing with Machine → Edited → Approved chips.
91+
- Reset/Unlock controls to manage overrides.
92+
- Length-based warnings + summary so HR spots risky strings fast.
93+
- Overrides feed every other view (single preview + export).
94+
95+
---
96+
97+
## 📦 Onboarding Pack Export
98+
99+
1. Choose a locale via the Employee panel dropdown.
100+
2. Ensure QA overrides are final (Approved if needed).
101+
3. Click **Download Onboarding Pack** → generates `onboarding-pack-<locale>.doc` with:
102+
- Locale code
103+
- Localized company + role
104+
- Welcome note (SDK translation if non-English)
105+
- Full task list using effective text (overrides or machine)
106+
107+
Perfect for HRIS uploads, emails, or sharing with managers.
108+
109+
---
110+
111+
## 🛠 Tech Stack
112+
113+
- **Next.js 16** (App Router, TypeScript)
114+
- **Tailwind CSS 4** (custom gradient + glassmorphism theme)
115+
- **Lingo.dev CLI, JS SDK, CI**
116+
- **next-themes** + custom design tokens for dark-first UI
117+
- **GitHub Actions** for automated localization runs
118+
119+
---
120+
121+
## 📁 Project Structure
122+
123+
```text
124+
app/
125+
layout.tsx # Root metadata + ThemeProvider
126+
page.tsx # HR + Employee panels, QA, overrides, spinner
127+
globals.css # Tailwind layers + design tokens
128+
components/
129+
mode-toggle.tsx # Shadcn-style theme toggle (hidden by default)
130+
data/
131+
ui.*.json # Static UI translations (CLI managed)
132+
onboarding_template.*.json
133+
lib/
134+
i18n.ts # Typed loaders for JSON bundles
135+
lingo-client.ts # SDK setup + runtime translation helpers
136+
.github/workflows/
137+
i18n.yml # CI job running `lingo.dev ci`
138+
i18n.json # Bucket + locale configuration
139+
```
140+
141+
---
142+
143+
## 🧾 Useful Scripts
144+
145+
- `npm run dev` – Next.js dev server
146+
- `npm run build` – Production build
147+
- `npm run lint` – ESLint via `eslint-config-next`
148+
149+
---
150+
151+
## ✅ Hackathon Compliance & Notes
152+
153+
- All code, UI, and assets created fresh during **LingoHack25**.
154+
- API keys are required only for translation features; none are checked into the repo.
155+
- Want more locales? Add them to `SUPPORTED_LOCALES` + `i18n.json`, re-run the CLI, and you’re done.
156+
157+
---
158+
159+
### 💬 Questions for Judges?
160+
Open an issue or ping me — I'd love to show how GlobalOnboard can become the multilingual onboarding cockpit for any global company.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { NextResponse } from "next/server";
2+
3+
import { translateWithLingo } from "@/lib/lingo";
4+
import { SUPPORTED_LOCALES, type Locale } from "@/lib/i18n";
5+
6+
type TranslationPayload = {
7+
text?: string;
8+
targetLocale?: Locale;
9+
};
10+
11+
const MAX_TEXT_LENGTH = 2000;
12+
13+
export async function POST(request: Request) {
14+
let payload: TranslationPayload;
15+
16+
try {
17+
payload = (await request.json()) as TranslationPayload;
18+
} catch (error) {
19+
console.error("Invalid translation payload", error);
20+
return NextResponse.json({ error: "Invalid request body" }, { status: 400 });
21+
}
22+
23+
const { text, targetLocale } = payload;
24+
25+
if (!text || typeof text !== "string") {
26+
return NextResponse.json({ error: "Missing welcome note" }, { status: 400 });
27+
}
28+
29+
if (text.length > MAX_TEXT_LENGTH) {
30+
return NextResponse.json({ error: "Welcome note is too long" }, { status: 413 });
31+
}
32+
33+
if (!targetLocale || !SUPPORTED_LOCALES.includes(targetLocale)) {
34+
return NextResponse.json({ error: "Unsupported locale" }, { status: 400 });
35+
}
36+
37+
try {
38+
const translated = await translateWithLingo(text, targetLocale);
39+
return NextResponse.json({ translated });
40+
} catch (error) {
41+
console.error("Lingo translation failed", error);
42+
return NextResponse.json(
43+
{ error: "Unable to translate welcome note" },
44+
{ status: 500 },
45+
);
46+
}
47+
}
25.3 KB
Binary file not shown.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@import "tailwindcss";
2+
3+
@source "../app/**/*.{js,ts,jsx,tsx}";
4+
@source "../components/**/*.{js,ts,jsx,tsx}";
5+
@source "../lib/**/*.{js,ts,jsx,tsx}";
6+
7+
:root {
8+
--background: linear-gradient(135deg, #e3f2ff, #f9f1ff);
9+
--foreground: #0f172a;
10+
--muted: rgba(255, 255, 255, 0.8);
11+
--muted-foreground: #475569;
12+
--panel-start: #eef2ff;
13+
--panel-end: #fdf2f8;
14+
}
15+
16+
@theme inline {
17+
--color-background: var(--background);
18+
--color-foreground: var(--foreground);
19+
--color-muted: var(--muted);
20+
--color-muted-foreground: var(--muted-foreground);
21+
--font-sans: "Inter", "Sohne", system-ui, -apple-system, blinkmacsystemfont,
22+
"Segoe UI", sans-serif;
23+
--font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
24+
}
25+
26+
body {
27+
background: var(--background);
28+
color: var(--foreground);
29+
font-family: var(--font-sans);
30+
transition: color 0.3s ease;
31+
background-attachment: fixed;
32+
}
Lines changed: 29 additions & 0 deletions
Loading
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type { Metadata } from "next";
2+
import "./globals.css";
3+
import { cn } from "@/lib/utils";
4+
5+
export const metadata: Metadata = {
6+
title: "GlobalOnboard",
7+
description:
8+
"GlobalOnboard lets HR teams create one onboarding checklist and preview it in multiple languages via Lingo.dev.",
9+
icons: {
10+
icon: [
11+
{ url: "/favicon.svg", type: "image/svg+xml" },
12+
{ url: "/favicon.svg", rel: "alternate icon", type: "image/svg+xml" },
13+
],
14+
},
15+
};
16+
17+
export default function RootLayout({
18+
children,
19+
}: Readonly<{
20+
children: React.ReactNode;
21+
}>) {
22+
return (
23+
<html lang="en" suppressHydrationWarning>
24+
<body
25+
className={cn(
26+
"min-h-screen bg-background text-foreground antialiased transition-colors",
27+
)}
28+
>
29+
{children}
30+
</body>
31+
</html>
32+
);
33+
}

0 commit comments

Comments
 (0)