Skip to main content

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

strings.xml
<?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:

ValueDescription
zeroZero items (some languages)
oneExactly one
twoExactly two (some languages)
fewSmall number (language-specific)
manyLarge number (language-specific)
otherRequired — default case

Non-Translatable Strings

<string name="api_key" translatable="false">abc123xyz</string>
info

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">&lt;b&gt;Bold&lt;/b&gt;</string>

<!-- Ampersand -->
<string name="company">Tom &amp; 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).

Multiple Files

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

ContentImportedNotes
<string> elements✅ YesName attribute = key
<plurals> elements✅ Yesother variant preferred
Format specifiers (%s, %d)✅ YesPreserved as-is
translatable="false"❌ NoAutomatically skipped
Comments❌ NoNot transferred
String arrays❌ NoNot supported

Locale Detection

Azbox detects the locale from the folder name:

FolderDetected 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

  1. Use descriptive nameslogin_button_text not btn1
  2. Group related strings — Use prefixes like login_, profile_, settings_
  3. Keep format consistent — Same placeholders across all languages
  4. Mark non-translatable — API keys, URLs, constants
  5. One file per language — Import each strings.xml separately

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