Android XML Import
Azbox supports Android strings.xml files, the standard localization format for Android applications built with Kotlin or Java.
What are Android XML Files?
Android uses XML files to store string resources. The main file is strings.xml, located in the res/values/ directory for the default language, and res/values-{locale}/ for other languages.
app/
└── src/main/res/
├── values/
│ └── strings.xml ← Default (English)
├── values-es/
│ └── strings.xml ← Spanish
├── values-fr/
│ └── strings.xml ← French
└── values-de/
└── strings.xml ← German
File Format
Basic Structure
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">My App</string>
<string name="welcome_message">Welcome!</string>
<string name="login_button">Log In</string>
</resources>
String Formatting
Use %s for strings, %d for integers, %f for floats:
<resources>
<string name="greeting">Hello, %s!</string>
<string name="items_count">You have %d items</string>
<string name="price">Total: $%.2f</string>
</resources>
Positional arguments with %1$s, %2$s:
<string name="welcome_back">Welcome back, %1$s! You have %2$d notifications.</string>
Plurals
<resources>
<plurals name="items_count">
<item quantity="zero">No items</item>
<item quantity="one">%d item</item>
<item quantity="other">%d items</item>
</plurals>
</resources>
Quantity values:
| Value | Description |
|---|---|
zero | Zero items (some languages) |
one | Exactly one |
two | Exactly two (some languages) |
few | Small number (language-specific) |
many | Large number (language-specific) |
other | Required — default case |
Non-Translatable Strings
<string name="api_key" translatable="false">abc123xyz</string>
Azbox automatically skips strings with translatable="false".
Special Characters
Escape special characters:
<resources>
<!-- Apostrophe -->
<string name="dont">Don\'t worry</string>
<!-- Quotes -->
<string name="quoted">\"Hello\"</string>
<!-- HTML -->
<string name="bold"><b>Bold</b></string>
<!-- Ampersand -->
<string name="company">Tom & Jerry</string>
</resources>
Complete Example
English (values/strings.xml):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">My Shop</string>
<string name="welcome">Welcome to My Shop!</string>
<string name="greeting">Hello, %s!</string>
<string name="search_hint">Search products...</string>
<string name="add_to_cart">Add to Cart</string>
<string name="checkout">Checkout</string>
<plurals name="cart_items">
<item quantity="zero">Cart is empty</item>
<item quantity="one">%d item in cart</item>
<item quantity="other">%d items in cart</item>
</plurals>
<string name="api_endpoint" translatable="false">https://api.myshop.com</string>
</resources>
Spanish (values-es/strings.xml):
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Mi Tienda</string>
<string name="welcome">¡Bienvenido a Mi Tienda!</string>
<string name="greeting">¡Hola, %s!</string>
<string name="search_hint">Buscar productos...</string>
<string name="add_to_cart">Añadir al Carrito</string>
<string name="checkout">Pagar</string>
<plurals name="cart_items">
<item quantity="zero">Carrito vacío</item>
<item quantity="one">%d artículo en el carrito</item>
<item quantity="other">%d artículos en el carrito</item>
</plurals>
</resources>
How to Import in Azbox
Step 1: Open Import Dialog
Click Import in your project dashboard.
Step 2: Select Format
Choose Android (.xml) from the dropdown.
Step 3: Select Language
Pick the target language for the file you're importing.
Step 4: Import File(s)
Click Import and select your strings.xml file(s).
You can select multiple XML files at once. All translations will be assigned to the selected language.
Step 5: Review Results
Check the summary:
- ✅ Imported keywords
- ⚠️ Skipped (empty values,
translatable="false") - ❌ Errors (invalid XML)
What Gets Imported
| Content | Imported | Notes |
|---|---|---|
<string> elements | ✅ Yes | Name attribute = key |
<plurals> elements | ✅ Yes | other variant preferred |
Format specifiers (%s, %d) | ✅ Yes | Preserved as-is |
translatable="false" | ❌ No | Automatically skipped |
| Comments | ❌ No | Not transferred |
| String arrays | ❌ No | Not supported |
Locale Detection
Azbox detects the locale from the folder name:
| Folder | Detected Locale |
|---|---|
values/ | en (default) |
values-es/ | es |
values-fr/ | fr |
values-pt-rBR/ | pt |
values-zh-rCN/ | zh |
Usage in Android
Kotlin:
// Simple string
getString(R.string.welcome)
// With formatting
getString(R.string.greeting, userName)
// Plurals
resources.getQuantityString(R.plurals.cart_items, count, count)
XML layout:
<TextView
android:text="@string/welcome"
... />
Jetpack Compose:
Text(stringResource(R.string.welcome))
Text(stringResource(R.string.greeting, userName))
Best Practices
- Use descriptive names —
login_button_textnotbtn1 - Group related strings — Use prefixes like
login_,profile_,settings_ - Keep format consistent — Same placeholders across all languages
- Mark non-translatable — API keys, URLs, constants
- One file per language — Import each
strings.xmlseparately
Project Structure
app/src/main/res/
├── values/
│ └── strings.xml ← Import as English
├── values-es/
│ └── strings.xml ← Import as Spanish
├── values-fr/
│ └── strings.xml ← Import as French
├── values-de/
│ └── strings.xml ← Import as German
└── values-ja/
└── strings.xml ← Import as Japanese
Related
- ARB Import — For Flutter
- JSON Import — For JavaScript
- Android Localization Guide