Skip to content

Commit 5891cd2

Browse files
committed
refactor: share translations from main web app instead of duplicating
- Templates app now imports and merges translations from main web app - Only templates-specific translations remain in templates/common.json - Fixes blank Solutions menu by inheriting nav.solutions.*.items arrays - Single source of truth for shared nav translations
1 parent edb592d commit 5891cd2

2 files changed

Lines changed: 11 additions & 131 deletions

File tree

apps/templates/public/locales/en/common.json

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -1,133 +1,4 @@
11
{
2-
"commands": {
3-
"toggle": "Toggle",
4-
"search": "Search"
5-
},
6-
"developers": {
7-
"nav": {
8-
"documentation": "Documentation",
9-
"cookbook": "Cookbook",
10-
"rpc": "RPC"
11-
}
12-
},
13-
"footer": {
14-
"copyright": "© {currentYear} Solana Foundation. All rights reserved.",
15-
"foundation": "Solana Foundation",
16-
"get-connected": {
17-
"heading": "Get Connected",
18-
"blog": "Blog",
19-
"newsletter": "Newsletter"
20-
},
21-
"solana": {
22-
"heading": "Solana",
23-
"break": "Breakpoint",
24-
"careers": "Careers",
25-
"disclaimer": "Disclaimer",
26-
"grants": "Grants",
27-
"media": "Media Kit",
28-
"privacy-policy": "Privacy Policy"
29-
}
30-
},
31-
"learn": {
32-
"tutorials": {
33-
"items": {
34-
"introduction-to-defi-on-solana": {
35-
"title": "Introduction to DeFi on Solana"
36-
},
37-
"what-is-a-wallet": {
38-
"title": "What is a Wallet?"
39-
},
40-
"what-is-solana": {
41-
"title": "What is Solana?"
42-
}
43-
}
44-
}
45-
},
46-
"nav": {
47-
"community": {
48-
"title": "Community",
49-
"event": {
50-
"title": "Events"
51-
},
52-
"involved": {
53-
"title": "Get Involved"
54-
}
55-
},
56-
"developers": {
57-
"title": "Developers",
58-
"items": {
59-
"title": "Developer Resources",
60-
"api": {
61-
"title": "RPC API",
62-
"description": "Interact with Solana nodes"
63-
},
64-
"cookbook": {
65-
"title": "Cookbook",
66-
"description": "Code examples and references"
67-
},
68-
"docs": {
69-
"title": "Documentation",
70-
"description": "Learn how to build on Solana"
71-
},
72-
"hub": {
73-
"title": "Developer Hub",
74-
"description": "All developer resources in one place"
75-
}
76-
},
77-
"tutorials": {
78-
"title": "Tutorials",
79-
"evm-to-svm": "EVM to SVM",
80-
"hello-world": "Hello World",
81-
"local-setup": "Local Setup"
82-
}
83-
},
84-
"learn": {
85-
"title": "Learn",
86-
"start": {
87-
"title": "Get Started",
88-
"items": {
89-
"all": {
90-
"title": "View All",
91-
"description": "Browse all learning resources"
92-
},
93-
"defi": {
94-
"description": "Decentralized finance on Solana"
95-
},
96-
"universities": {
97-
"title": "Universities",
98-
"description": "Academic programs and courses"
99-
},
100-
"wallet": {
101-
"description": "Understanding crypto wallets"
102-
},
103-
"what-is-solana": {
104-
"description": "Introduction to Solana blockchain"
105-
}
106-
}
107-
}
108-
},
109-
"network": {
110-
"title": "Network",
111-
"inspect": {
112-
"title": "Inspect"
113-
},
114-
"resources": {
115-
"title": "Resources"
116-
}
117-
},
118-
"solutions": {
119-
"title": "Solutions",
120-
"cases": {
121-
"title": "Use Cases"
122-
},
123-
"resources": {
124-
"title": "Resources"
125-
},
126-
"tools": {
127-
"title": "Tools"
128-
}
129-
}
130-
},
1312
"templates": {
1323
"title": "Solana Developer Templates",
1334
"subtitle": "Build faster with production-ready templates for dApps, DeFi protocols, NFT marketplaces, and more. Get started with battle-tested code patterns optimized for the Solana ecosystem.",

apps/templates/src/app/[locale]/layout.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,20 @@ type Props = {
1111
export default async function LocaleLayout({ children, params }: Props) {
1212
const { locale = "en" } = await params;
1313
const direction = getLangDir(locale);
14-
// Load messages directly
15-
const messages = (
14+
15+
// Load messages from main web app (shared translations)
16+
const webMessages = (
17+
await import(`../../../../../apps/web/public/locales/${locale}/common.json`)
18+
).default;
19+
20+
// Load templates-specific messages
21+
const templatesMessages = (
1622
await import(`../../../public/locales/${locale}/common.json`)
1723
).default;
1824

25+
// Merge translations, with templates-specific taking precedence
26+
const messages = { ...webMessages, ...templatesMessages };
27+
1928
return (
2029
<html
2130
lang={locale}

0 commit comments

Comments
 (0)