Android XML Localization - LocEngine Features

Android XML Localization

Complete guide to localizing Android apps with LocEngine

Overview

Android applications store all translatable text in XML resource files. LocEngine provides comprehensive support for scanning, extracting, and injecting translations into Android projects, including support for plural strings, string arrays, and resource qualifiers.

Key Features

📁 Full Resource Support

Complete support for strings.xml, plurals.xml, arrays.xml, and all resource qualifiers (values-fa, values-ar, values-en-rUS, etc.)

🔍 Smart Detection

Automatically detects hardcoded strings in Java/Kotlin code and suggests moving them to resources

🌍 Language Management

Easily add new languages, manage translations across all resource folders, and ensure consistency

🔄 Safe Injection

Automatically inject translations back into the correct resource files with backup and rollback

Working with String Resources

Basic string resources are stored in res/values/strings.xml:

<!-- res/values/strings.xml -->
<resources>
  <string name="app_name">My Awesome App</string>
  <string name="welcome_message">Welcome to our application!</string>
  <string name="button_save">Save Changes</string>
  <string name="button_cancel">Cancel</string>
  <string name="user_greeting">Hello, %s!</string>
</resources>

Adding New Languages

LocEngine automatically creates language-specific resource folders:

res/
├── values/ (default - usually English)
│ └── strings.xml
├── values-fa/ (Persian)
│ └── strings.xml
├── values-ar/ (Arabic - RTL)
│ └── strings.xml
├── values-es-rMX/ (Mexican Spanish)
│ └── strings.xml
└── values-pt-rBR/ (Brazilian Portuguese)
└── strings.xml

Working with Plurals

Android's plural system handles language-specific quantity rules:

<!-- res/values/strings.xml -->
<plurals name="number_of_messages">
  <item quantity="one">%d message</item>
  <item quantity="other">%d messages</item>
</plurals>

<!-- res/values-fa/strings.xml (Persian) -->
<plurals name="number_of_messages">
  <item quantity="one">%d پیام</item>
  <item quantity="other">%d پیام</item>
</plurals>

String Arrays for Lists

<string-array name="days_of_week">
  <item>Monday</item>
  <item>Tuesday</item>
  <item>Wednesday</item>
  <item>Thursday</item>
  <item>Friday</item>
  <item>Saturday</item>
  <item>Sunday</item>
</string-array>

Detecting Hardcoded Strings

LocEngine finds strings directly in your code and suggests moving them to resources:

// Before (hardcoded)
TextView textView = findViewById(R.id.textView);
textView.setText("Welcome to our app!");

// After (using resources)
TextView textView = findViewById(R.id.textView);
textView.setText(R.string.welcome_message);
💡 Pro Tip: Use LocEngine's batch detection to find all hardcoded strings in your project at once. It can automatically generate resource entries and replace the code in one operation.

RTL Language Support

Android has excellent RTL support. LocEngine helps you manage RTL-specific resources:

  • Automatic mirroring of layouts for RTL languages
  • Support for start/end attributes instead of left/right
  • RTL-aware string validation
  • Special handling for numbers and punctuation in RTL context

Integration with Android Studio

LocEngine works seamlessly with Android projects:

  • Preserves Gradle build files and project structure
  • Works with both Java and Kotlin
  • Compatible with AndroidX and support libraries
  • No changes to your build process required