mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 14:22:28 +08:00
* i18n support added
* fix: align i18n implementation with Next.js 16 guide
- Rename middleware.ts to proxy.ts (Next.js 16 convention)
- Fix params type to Promise<{lang: string}> for layout/metadata
- Add 'server-only' directive and dynamic imports to dictionaries.ts
- Add hasLocale type guard and notFound() for invalid locales
- Wrap LanguageToggle in Suspense for useSearchParams
- Fix dictionary key mismatch (learnmore -> learnMore)
- Improve Chinese translations per Gemini review:
- loading ellipsis, new -> 新建, styledMode -> 精致
- goodResponse/badResponse -> 有帮助/无帮助
- closeProtection -> 关闭确认, fileExceeds phrasing
- Improve Japanese translations per Gemini review:
- closeProtection -> ページ離脱確認
- invalidAccessCode phrasing, appendDiagram -> に追加
- styledMode -> スタイル付き
---------
Co-authored-by: dayuan.jiang <jdy.toh@gmail.com>
15 lines
380 B
TypeScript
15 lines
380 B
TypeScript
export function formatMessage(
|
|
template: string | undefined,
|
|
vars?: Record<string, string | number | undefined>,
|
|
): string {
|
|
if (!template) return ""
|
|
if (!vars) return template
|
|
|
|
return template.replace(/\{(\w+)\}/g, (match, name) => {
|
|
const val = vars[name]
|
|
return val === undefined ? match : String(val)
|
|
})
|
|
}
|
|
|
|
export default formatMessage
|