@studyjoyful/shared 1.0.1 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/package.json +1 -2
- package/src/i18n/locales/en/auth.json +16 -3
package/README.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
Shared code for StudyJoyful Web and App.
|
|
4
4
|
|
|
5
|
+
## 🎯 Design Principles
|
|
6
|
+
|
|
7
|
+
### i18n: Single Source of Truth
|
|
8
|
+
|
|
9
|
+
> ⚠️ **Critical**: This package is the **ONLY** source of translations.
|
|
10
|
+
> Web and App do NOT have their own `locales/` directories.
|
|
11
|
+
|
|
12
|
+
| Principle | Description |
|
|
13
|
+
| ----------------- | --------------------------------------- |
|
|
14
|
+
| **Single Source** | All translations here, nowhere else |
|
|
15
|
+
| **English Only** | Singapore market = English only |
|
|
16
|
+
| **Modular** | Split by feature (auth, chat, tasks...) |
|
|
17
|
+
| **Shared** | Web + App import from this package |
|
|
18
|
+
|
|
5
19
|
## 📦 Modules
|
|
6
20
|
|
|
7
21
|
| Module | Description | Exports |
|
|
@@ -111,6 +125,55 @@ npx tsc --noEmit
|
|
|
111
125
|
3. Re-export from main `src/index.ts`
|
|
112
126
|
4. Test in both Web and App
|
|
113
127
|
|
|
128
|
+
## 🌍 Adding Translations
|
|
129
|
+
|
|
130
|
+
### DO:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Add to this package
|
|
134
|
+
src/i18n/locales/en/auth.json # ✅ Correct
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### DON'T:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
# Never create locales in consumer projects
|
|
141
|
+
studyjoyful-app/locales/ # ❌ WRONG
|
|
142
|
+
studyjoyful-web/locales/ # ❌ WRONG
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Translation File Structure
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
// src/i18n/locales/en/auth.json
|
|
149
|
+
{
|
|
150
|
+
"welcome": {
|
|
151
|
+
"title": "StudyJoyful",
|
|
152
|
+
"subtitle": "Turn homework into 10-minute learning games",
|
|
153
|
+
"getStarted": "Get Started"
|
|
154
|
+
},
|
|
155
|
+
"errors": {
|
|
156
|
+
"signInFailed": "Sign In Failed",
|
|
157
|
+
"tryAgain": "Please try again"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Usage in Consumer Projects
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
// lib/i18n.ts (in Web or App)
|
|
166
|
+
import { resources, namespaces, defaultNS } from "@studyjoyful/shared";
|
|
167
|
+
|
|
168
|
+
// Component
|
|
169
|
+
import { useTranslation } from "react-i18next";
|
|
170
|
+
|
|
171
|
+
function WelcomeScreen() {
|
|
172
|
+
const { t } = useTranslation("auth");
|
|
173
|
+
return <Text>{t("welcome.title")}</Text>;
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
114
177
|
---
|
|
115
178
|
|
|
116
179
|
**Package**: `@studyjoyful/shared`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studyjoyful/shared",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Shared code for StudyJoyful Web and App (i18n, constants, types, utils)",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -32,4 +32,3 @@
|
|
|
32
32
|
"typescript": "^5.7.3"
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
{
|
|
2
|
+
"welcome": {
|
|
3
|
+
"title": "StudyJoyful",
|
|
4
|
+
"subtitle": "Turn homework into 10-minute learning games",
|
|
5
|
+
"getStarted": "Get Started",
|
|
6
|
+
"termsAgreement": "By continuing, you agree to our",
|
|
7
|
+
"termsOfService": "Terms of Service",
|
|
8
|
+
"and": "and",
|
|
9
|
+
"privacyPolicy": "Privacy Policy"
|
|
10
|
+
},
|
|
2
11
|
"signIn": {
|
|
3
12
|
"title": "StudyJoyful",
|
|
4
13
|
"subtitle": "Joyful Learning Starts Here",
|
|
@@ -13,9 +22,11 @@
|
|
|
13
22
|
"codeSentTo": "Sent to {{email}}",
|
|
14
23
|
"codePlaceholder": "Enter 6-digit code",
|
|
15
24
|
"verifyAndSignIn": "Verify & Sign In",
|
|
25
|
+
"signInButton": "Sign In",
|
|
16
26
|
"back": "← Back",
|
|
17
27
|
"noAccount": "Don't have an account?",
|
|
18
|
-
"signUpNow": "Sign Up"
|
|
28
|
+
"signUpNow": "Sign Up",
|
|
29
|
+
"signUpLink": "Sign Up"
|
|
19
30
|
},
|
|
20
31
|
"signUp": {
|
|
21
32
|
"title": "Create Account",
|
|
@@ -29,9 +40,12 @@
|
|
|
29
40
|
"codeSentTo": "Sent to {{email}}",
|
|
30
41
|
"codePlaceholder": "Enter 6-digit code",
|
|
31
42
|
"verifyAndSignUp": "Verify & Sign Up",
|
|
43
|
+
"signUpButton": "Sign Up",
|
|
32
44
|
"back": "← Back",
|
|
33
45
|
"hasAccount": "Already have an account?",
|
|
46
|
+
"haveAccount": "Already have an account?",
|
|
34
47
|
"signInNow": "Sign In",
|
|
48
|
+
"signInLink": "Sign In",
|
|
35
49
|
"termsAgreement": "By creating an account, you agree to our",
|
|
36
50
|
"termsOfService": "Terms of Service",
|
|
37
51
|
"and": "and",
|
|
@@ -51,8 +65,7 @@
|
|
|
51
65
|
"retryOrResend": "Please retry or resend the code",
|
|
52
66
|
"googleSignInFailed": "Google sign in failed, please retry",
|
|
53
67
|
"googleSignUpFailed": "Google sign up failed, please retry",
|
|
54
|
-
"additionalInfoRequired": "Additional Information Required"
|
|
55
|
-
"checkClerkConfig": "Please check your Clerk Dashboard settings, or use Google sign in"
|
|
68
|
+
"additionalInfoRequired": "Additional Information Required"
|
|
56
69
|
},
|
|
57
70
|
"accountNotFound": {
|
|
58
71
|
"title": "Account Not Found",
|