Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pages/src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const LANG_OPTIONS: { value: Language; label: string }[] = [
{ value: 'en', label: 'English' },
{ value: 'zh', label: '中文' }, // allow-non-english: language options are labelled in their own language
{ value: 'ja', label: '日本語' }, // allow-non-english: language options are labelled in their own language
{ value: 'ko', label: '한국어' }, // allow-non-english: language options are labelled in their own language
{ value: 'ru', label: 'Русский' }, // allow-non-english: language options are labelled in their own language
];

Expand Down
13 changes: 12 additions & 1 deletion pages/src/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,27 @@ const LANG_OPTIONS: { value: Language; label: string }[] = [
{ value: 'en', label: 'English' },
{ value: 'zh', label: '中文' }, // allow-non-english: language options are labelled in their own language
{ value: 'ja', label: '日本語' }, // allow-non-english: language options are labelled in their own language
{ value: 'ko', label: '한국어' }, // allow-non-english: language options are labelled in their own language
{ value: 'ru', label: 'Русский' }, // allow-non-english: language options are labelled in their own language
];

const LANG_BADGE: Record<Language, string> = {
en: 'En',
zh: '中', // allow-non-english: single-glyph locale badge
ja: 'あ', // allow-non-english: single-glyph locale badge
ko: '한', // allow-non-english: single-glyph locale badge
ru: 'Ru',
};

// Locales whose badge glyph needs a script-specific face; everything else uses
// the default stack below.
const LANG_BADGE_FONT: Partial<Record<Language, string>> = {
ja: "'Hiragino Sans', sans-serif",
ko: "'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif",
};

const DEFAULT_LANG_BADGE_FONT = "'PingFang SC', -apple-system, sans-serif";

const navTabs = [
{ path: '/features', labelKey: 'navbar.features' },
{ path: '/benchmark', labelKey: 'navbar.benchmark' },
Expand Down Expand Up @@ -152,7 +163,7 @@ const Navbar: React.FC = () => {
lineHeight: '18px',
textAlign: 'center' as const,
width: '100%',
fontFamily: language === 'ja' ? "'Hiragino Sans', sans-serif" : "'PingFang SC', -apple-system, sans-serif",
fontFamily: LANG_BADGE_FONT[language] ?? DEFAULT_LANG_BADGE_FONT,
}}>
{LANG_BADGE[language]}
</span>
Expand Down
2 changes: 2 additions & 0 deletions pages/src/content/docs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ const docsMap: Record<Language, LocalizedDocs> = {
en: enDocs,
zh: zhDocs,
ja: jaDocs,
// Korean UI strings ship first; doc pages fall back to English until ko/ exists.
ko: {},
ru: ruDocs,
};

Expand Down
5 changes: 3 additions & 2 deletions pages/src/i18n/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { Language, TranslationKeys } from './types';
import { en } from './en';
import { zh } from './zh';
import { ja } from './ja';
import { ko } from './ko';
import { ru } from './ru';

const translations: Record<Language, TranslationKeys> = { en, zh, ja, ru };
const translations: Record<Language, TranslationKeys> = { en, zh, ja, ko, ru };

interface LanguageContextValue {
language: Language;
Expand All @@ -20,7 +21,7 @@ const LanguageContext = createContext<LanguageContextValue | null>(null);

const STORAGE_KEY = 'ocr-lang';

const SUPPORTED_LANGUAGES: Language[] = ['en', 'zh', 'ja', 'ru'];
const SUPPORTED_LANGUAGES: Language[] = ['en', 'zh', 'ja', 'ko', 'ru'];

function detectBrowserLanguage(): Language | null {
try {
Expand Down
318 changes: 318 additions & 0 deletions pages/src/i18n/ko.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pages/src/i18n/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

import type { en } from './en';

export type Language = 'en' | 'zh' | 'ja' | 'ru';
export type Language = 'en' | 'zh' | 'ja' | 'ko' | 'ru';
export type TranslationKey = keyof typeof en;
export type TranslationKeys = Record<TranslationKey, string>;
3 changes: 2 additions & 1 deletion pages/src/pages/NotFoundPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import { LanguageProvider } from '../i18n';
import { en } from '../i18n/en';
import { zh } from '../i18n/zh';
import { ja } from '../i18n/ja';
import { ko } from '../i18n/ko';
import { ru } from '../i18n/ru';
import type { Language, TranslationKeys } from '../i18n/types';

const translations: Record<Language, TranslationKeys> = { en, zh, ja, ru };
const translations: Record<Language, TranslationKeys> = { en, zh, ja, ko, ru };

function installLocalStorageMock() {
let store: Record<string, string> = {};
Expand Down
11 changes: 11 additions & 0 deletions pages/src/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ p {
margin: 0;
}

/* Korean separates words with spaces, so the browser default (which may break
between Hangul syllables) splits a word mid-token, leaving its tail alone on
the next line. Scoped to ko via the lang attribute set in i18n/context.tsx;
zh/ja rely on any-character line breaking and must keep the default.
overflow-wrap still lets an unbroken token (a long URL or identifier) wrap
instead of overflow. */
:lang(ko) {
word-break: keep-all;
overflow-wrap: break-word;
}

a {
text-decoration: none;
color: inherit;
Expand Down
Loading