Skip to content

Commit 2f6b6df

Browse files
author
qwe7002
committed
feat(docs): add documentation for string resources organization and update project instructions
1 parent b890871 commit 2f6b6df

3 files changed

Lines changed: 208 additions & 1 deletion

File tree

.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default defineConfigWithTheme<ExtendedConfig>({
3131
{ text: "Data Structure - Quick Guide", link: "/DATA_STRUCTURE_VERSION_QUICK_EN" },
3232
{ text: "Self-hosted Bot API", link: "/self_hosted_bot_api" },
3333
{ text: "Carbon Copy Provider Implementation", link: "/CarbonCopyProvider" },
34+
{ text: "String Resources Organization", link: "/STRING_RESOURCES" },
3435
],
3536
},
3637
{

docs/STRING_RESOURCES.md

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
# String Resources Organization
2+
3+
This document describes how string resources are organized in the Telegram SMS project to improve maintainability and clarity.
4+
5+
## Overview
6+
7+
String resources are split into multiple XML files based on their functional area, rather than having all strings in a single `strings.xml` file. This modular approach makes it easier for developers and translators to locate and manage strings.
8+
9+
## File Structure
10+
11+
All string resource files are located in:
12+
- `app/src/main/res/values/` (English - default)
13+
- `app/language_pack/values-{locale}/` (Translated versions)
14+
15+
### Core Files
16+
17+
#### `strings.xml`
18+
Contains only base configuration strings:
19+
- `Lang`: Language identifier
20+
- `time_format`: Date/time format string
21+
22+
#### `strings_battery.xml`
23+
Battery monitoring related strings:
24+
- Battery level notifications
25+
- Charger status messages
26+
- Battery monitoring service names
27+
28+
#### `strings_telegram.xml`
29+
Telegram API and bot related strings:
30+
- Bot token configuration
31+
- Chat ID setup
32+
- API connection messages
33+
- Chat command responses
34+
- Privacy mode settings
35+
36+
#### `strings_sms.xml`
37+
SMS related strings:
38+
- SMS forwarding settings
39+
- Trusted phone numbers
40+
- Verification code detection
41+
- SMS templates
42+
- SMS blocklist/spam filtering
43+
- Reply message prompts
44+
45+
#### `strings_call.xml`
46+
Phone call related strings:
47+
- Incoming call notifications
48+
- Missed call notifications
49+
- Call receiver settings
50+
- Phone number display options
51+
52+
#### `strings_ussd.xml`
53+
USSD code related strings:
54+
- USSD execution messages
55+
- USSD code input prompts
56+
- USSD format validation
57+
58+
#### `strings_network.xml`
59+
Network and connectivity related strings:
60+
- Network status messages
61+
- Airplane mode detection
62+
- DNS over HTTPS settings
63+
- Proxy configuration (Socks5)
64+
65+
#### `strings_cc.xml`
66+
Carbon Copy (CC) service related strings:
67+
- CC service configuration
68+
- CC service enable/disable states
69+
- CC service management UI
70+
71+
#### `strings_notification.xml`
72+
Notification listener related strings:
73+
- Notification listener service
74+
- Notification forwarding settings
75+
- App name and title display
76+
77+
#### `strings_scanner.xml`
78+
QR code scanner and configuration transfer strings:
79+
- QR code scanning UI
80+
- Configuration encryption/decryption
81+
- Configuration transfer messages
82+
- Camera permission requests
83+
84+
#### `strings_privacy_about.xml`
85+
App information and privacy related strings:
86+
- User manual links
87+
- Privacy policy
88+
- Donation information
89+
- About dialog content
90+
- Update check messages
91+
92+
#### `strings_common.xml`
93+
Common UI elements and general strings:
94+
- Button labels (OK, Cancel, Delete, Send, Reset)
95+
- Status messages (Success, Failed, Sending)
96+
- Log viewer
97+
- Error messages
98+
- System message headers
99+
100+
## Translation Workflow
101+
102+
When adding new strings:
103+
104+
1. **Add to English default** (`app/src/main/res/values/`)
105+
- Choose the appropriate category file
106+
- Use descriptive string IDs
107+
- Add the English text
108+
109+
2. **Update language pack** (`app/language_pack/`)
110+
- Create or update the same XML file in each locale folder
111+
- Ensure the string ID matches the English version
112+
- Translate the content
113+
114+
3. **Supported Languages**:
115+
- `values-zh-rCN/` - Simplified Chinese
116+
- `values-zh-rTW/` - Traditional Chinese
117+
- `values-zh-rHK/` - Hong Kong Chinese
118+
- `values-yue-rCN/` - Cantonese (China)
119+
- `values-yue-rHK/` - Cantonese (Hong Kong)
120+
- `values-ja-rJP/` - Japanese
121+
- `values-es-rES/` - Spanish
122+
- `values-ru/` - Russian
123+
- `values-vi/` - Vietnamese
124+
125+
## Best Practices
126+
127+
### String Naming Convention
128+
129+
Use descriptive prefixes to indicate string purpose:
130+
- Feature-specific: `sms_`, `call_`, `ussd_`, `battery_`, `cc_`
131+
- UI elements: `button_`, `title_`, `message_`
132+
- Status: `status_`, `error_`, `success_`
133+
134+
### File Selection Guidelines
135+
136+
When deciding which file to add a new string to:
137+
138+
1. **Identify the feature**: What component uses this string?
139+
2. **Check existing strings**: Look for similar strings in category files
140+
3. **Consider dependencies**: If a string is used by multiple features, put it in `strings_common.xml`
141+
4. **Avoid duplication**: Reuse existing strings when possible
142+
143+
### Examples
144+
145+
#### Good: Feature-specific placement
146+
```xml
147+
<!-- strings_sms.xml -->
148+
<string name="send_sms_title">Send SMS</string>
149+
<string name="receive_sms_title">Receive SMS</string>
150+
```
151+
152+
#### Good: Common element in common file
153+
```xml
154+
<!-- strings_common.xml -->
155+
<string name="ok_button">OK</string>
156+
<string name="cancel_button">Cancel</string>
157+
```
158+
159+
#### Bad: Wrong category
160+
```xml
161+
<!-- Don't put SMS strings in battery file -->
162+
<!-- strings_battery.xml -->
163+
<string name="send_sms_title">Send SMS</string> <!-- WRONG! -->
164+
```
165+
166+
## Migration from Single File
167+
168+
The original `strings.xml` file has been split into multiple category files. This was done to:
169+
- Improve code organization
170+
- Make translation easier
171+
- Reduce merge conflicts
172+
- Enable better code navigation
173+
174+
All string IDs remain unchanged, so no code modifications are required. Android's resource system automatically merges all string XML files at build time.
175+
176+
## Verification
177+
178+
To verify all strings are properly organized:
179+
180+
1. **Build the project**: `./gradlew assembleDebug`
181+
2. **Check for duplicate IDs**: The build will fail if string IDs are duplicated across files
182+
3. **Test all features**: Ensure all strings are displayed correctly in the app
183+
184+
## Future Considerations
185+
186+
- Consider splitting `strings_sms.xml` further if SMS features expand significantly
187+
- Add automated tools to check string coverage across all locales
188+
- Implement string usage analysis to identify unused strings
189+

docs/instructions/project.instructions.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ telegram-sms/
154154
These are standalone VitePress documentation sites (not git submodules):
155155

156156
- **docs/**: Developer documentation (English only)
157-
- Contains: API docs, Carbon Copy Provider guide, Crypto documentation, Data structure guides
157+
- Contains: API docs, Carbon Copy Provider guide, Crypto documentation, Data structure guides, String Resources Organization
158158
- Built with VitePress
159159
- Hosted separately from main repository
160160

@@ -321,6 +321,23 @@ Language packs are copied during build via the `copy_language_pack` Gradle task.
321321
- English commits are welcome for contributions
322322
- Kotlin coding conventions
323323

324+
### String Resources Organization
325+
String resources are split into multiple category-based XML files for better maintainability:
326+
- **strings.xml**: Base configuration (Lang, time_format)
327+
- **strings_battery.xml**: Battery monitoring
328+
- **strings_telegram.xml**: Telegram API and bot
329+
- **strings_sms.xml**: SMS forwarding and management
330+
- **strings_call.xml**: Phone call notifications
331+
- **strings_ussd.xml**: USSD codes
332+
- **strings_network.xml**: Network and connectivity
333+
- **strings_cc.xml**: Carbon Copy services
334+
- **strings_notification.xml**: Notification listener
335+
- **strings_scanner.xml**: QR code scanner
336+
- **strings_privacy_about.xml**: Privacy and app info
337+
- **strings_common.xml**: Common UI elements
338+
339+
See [STRING_RESOURCES.md](../STRING_RESOURCES.md) for detailed guidelines on adding and organizing strings.
340+
324341
### Branch Strategy
325342
- `master`: Stable releases
326343
- `nightly`: Pre-release/nightly builds

0 commit comments

Comments
 (0)