|
| 1 | +--- |
| 2 | +name: add-translation |
| 3 | +description: Add new language translations to the library |
| 4 | +argument-hint: "<language-code> [language-name]" |
| 5 | +level: 1 |
| 6 | +triggers: |
| 7 | + - "add translation" |
| 8 | + - "translate" |
| 9 | + - "new language" |
| 10 | +--- |
| 11 | + |
| 12 | +# Add Translation Skill |
| 13 | + |
| 14 | +Add support for new languages or update existing translations. |
| 15 | + |
| 16 | +## Usage |
| 17 | + |
| 18 | +Run this skill when adding translations for a new language or updating existing ones. |
| 19 | + |
| 20 | +## Translation Files |
| 21 | + |
| 22 | +Translations are located in: |
| 23 | +``` |
| 24 | +cropper/src/main/res/ |
| 25 | +├── values/strings.xml # English (default) |
| 26 | +├── values-es/strings.xml # Spanish |
| 27 | +├── values-fr/strings.xml # French |
| 28 | +├── values-hi/strings.xml # Hindi |
| 29 | +├── values-ml/strings.xml # Malayalam |
| 30 | +├── values-da/strings.xml # Danish |
| 31 | +└── values-{lang}/strings.xml # Other languages |
| 32 | +``` |
| 33 | + |
| 34 | +## String Keys |
| 35 | + |
| 36 | +Based on `values/strings.xml`, the library has these translatable strings: |
| 37 | + |
| 38 | +```xml |
| 39 | +<resources> |
| 40 | + <string name="crop_image_menu_crop">Crop</string> |
| 41 | + <string name="pick_image_intent_chooser_title">Select source</string> |
| 42 | + <string name="crop_image_activity_no_permissions">Cancelling, required permissions are not granted</string> |
| 43 | + <string name="crop_image_menu_rotate_left">Rotate left</string> |
| 44 | + <string name="crop_image_menu_rotate_right">Rotate right</string> |
| 45 | + <string name="crop_image_menu_flip">Flip</string> |
| 46 | + <string name="crop_image_menu_flip_horizontally">Flip horizontally</string> |
| 47 | + <string name="crop_image_menu_flip_vertically">Flip vertically</string> |
| 48 | +</resources> |
| 49 | +``` |
| 50 | + |
| 51 | +## Steps to Add New Language |
| 52 | + |
| 53 | +### 1. Create Language Directory |
| 54 | +```bash |
| 55 | +mkdir -p cropper/src/main/res/values-{language-code}/ |
| 56 | +``` |
| 57 | + |
| 58 | +**Common Language Codes:** |
| 59 | +- Spanish: `es` |
| 60 | +- French: `fr` |
| 61 | +- German: `de` |
| 62 | +- Italian: `it` |
| 63 | +- Portuguese: `pt` |
| 64 | +- Japanese: `ja` |
| 65 | +- Korean: `ko` |
| 66 | +- Chinese (Simplified): `zh-rCN` |
| 67 | +- Chinese (Traditional): `zh-rTW` |
| 68 | +- Hindi: `hi` |
| 69 | +- Arabic: `ar` |
| 70 | +- Russian: `ru` |
| 71 | + |
| 72 | +### 2. Create strings.xml |
| 73 | + |
| 74 | +Copy the template: |
| 75 | +```xml |
| 76 | +<?xml version="1.0" encoding="utf-8"?> |
| 77 | +<resources> |
| 78 | + <string name="crop_image_menu_crop">[Translation for "Crop"]</string> |
| 79 | + <string name="pick_image_intent_chooser_title">[Translation for "Select source"]</string> |
| 80 | + <string name="crop_image_activity_no_permissions">[Translation for "Cancelling, required permissions are not granted"]</string> |
| 81 | + <string name="crop_image_menu_rotate_left">[Translation for "Rotate left"]</string> |
| 82 | + <string name="crop_image_menu_rotate_right">[Translation for "Rotate right"]</string> |
| 83 | + <string name="crop_image_menu_flip">[Translation for "Flip"]</string> |
| 84 | + <string name="crop_image_menu_flip_horizontally">[Translation for "Flip horizontally"]</string> |
| 85 | + <string name="crop_image_menu_flip_vertically">[Translation for "Flip vertically"]</string> |
| 86 | +</resources> |
| 87 | +``` |
| 88 | + |
| 89 | +### 3. Translate Strings |
| 90 | + |
| 91 | +Replace `[Translation for ...]` with actual translations in target language. |
| 92 | + |
| 93 | +**Translation Guidelines:** |
| 94 | +- Keep technical terms consistent |
| 95 | +- Respect cultural context |
| 96 | +- Keep length similar to English (for UI fit) |
| 97 | +- Use formal/informal tone appropriate for language |
| 98 | +- Test with sample app in that language |
| 99 | + |
| 100 | +### 4. Verify Translation |
| 101 | + |
| 102 | +1. Change device language to new language |
| 103 | +2. Run sample app |
| 104 | +3. Verify all strings display correctly |
| 105 | +4. Check for truncation or overflow |
| 106 | +5. Ensure proper RTL support (for Arabic, Hebrew, etc.) |
| 107 | + |
| 108 | +### 5. Update CHANGELOG.md |
| 109 | + |
| 110 | +```markdown |
| 111 | +- Added [Language Name] language support [\#PR](url) ([your-handle](url)) |
| 112 | +``` |
| 113 | + |
| 114 | +## Example: Adding Portuguese (Brazil) |
| 115 | + |
| 116 | +### Create Directory |
| 117 | +```bash |
| 118 | +mkdir -p cropper/src/main/res/values-pt-rBR/ |
| 119 | +``` |
| 120 | + |
| 121 | +### Create strings.xml |
| 122 | +```xml |
| 123 | +<?xml version="1.0" encoding="utf-8"?> |
| 124 | +<resources> |
| 125 | + <string name="crop_image_menu_crop">Cortar</string> |
| 126 | + <string name="pick_image_intent_chooser_title">Selecionar origem</string> |
| 127 | + <string name="crop_image_activity_no_permissions">Cancelando, as permissões necessárias não foram concedidas</string> |
| 128 | + <string name="crop_image_menu_rotate_left">Girar à esquerda</string> |
| 129 | + <string name="crop_image_menu_rotate_right">Girar à direita</string> |
| 130 | + <string name="crop_image_menu_flip">Espelhar</string> |
| 131 | + <string name="crop_image_menu_flip_horizontally">Espelhar horizontalmente</string> |
| 132 | + <string name="crop_image_menu_flip_vertically">Espelhar verticalmente</string> |
| 133 | +</resources> |
| 134 | +``` |
| 135 | + |
| 136 | +### Update CHANGELOG.md |
| 137 | +```markdown |
| 138 | +- Added Brazilian Portuguese language support [\#XXX](url) ([yourusername](url)) |
| 139 | +``` |
| 140 | + |
| 141 | +## Updating Existing Translations |
| 142 | + |
| 143 | +### Find Missing Strings |
| 144 | +1. Check `values/strings.xml` for all strings |
| 145 | +2. Compare with existing translation |
| 146 | +3. Add missing strings |
| 147 | + |
| 148 | +### Update Translation |
| 149 | +1. Open `values-{lang}/strings.xml` |
| 150 | +2. Update or add strings |
| 151 | +3. Test in sample app |
| 152 | +4. Update CHANGELOG.md |
| 153 | + |
| 154 | +## RTL Language Support |
| 155 | + |
| 156 | +For RTL languages (Arabic, Hebrew, etc.): |
| 157 | + |
| 158 | +1. Create `values-{lang}/strings.xml` as normal |
| 159 | +2. Android handles RTL automatically |
| 160 | +3. Test UI layout in RTL mode |
| 161 | +4. Ensure crop window works correctly |
| 162 | + |
| 163 | +## Quality Checklist |
| 164 | + |
| 165 | +- [ ] All string keys from `values/strings.xml` translated |
| 166 | +- [ ] No missing translations |
| 167 | +- [ ] Proper XML encoding (UTF-8) |
| 168 | +- [ ] Proper XML format |
| 169 | +- [ ] Tested in sample app |
| 170 | +- [ ] No UI overflow/truncation |
| 171 | +- [ ] CHANGELOG.md updated |
| 172 | +- [ ] Language code is correct |
| 173 | + |
| 174 | +## Common Issues |
| 175 | + |
| 176 | +### Issue: Strings not appearing |
| 177 | +**Solution**: Check language code is correct, rebuild app |
| 178 | + |
| 179 | +### Issue: Special characters broken |
| 180 | +**Solution**: Ensure file is UTF-8 encoded |
| 181 | + |
| 182 | +### Issue: Text truncated |
| 183 | +**Solution**: Keep translations similar length or adjust UI |
| 184 | + |
| 185 | +## Testing |
| 186 | + |
| 187 | +```bash |
| 188 | +# Build and install sample app |
| 189 | +./gradlew :sample:installDebug |
| 190 | + |
| 191 | +# Change device language to test language |
| 192 | +# Open sample app |
| 193 | +# Verify all strings appear correctly |
| 194 | +``` |
| 195 | + |
| 196 | +--- |
| 197 | + |
| 198 | +*Quality translations improve user experience worldwide.* |
0 commit comments