|
| 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 | + |
0 commit comments