Zero-dependency Android strings.xml translation and verification using LLMs (Gemini, OpenAI, Anthropic, Ollama).
Project description
Android LLM Localization
A zero-dependency Python tool to translate, fix, and verify Android strings.xml resources using Large Language Models (LLMs) — Gemini, OpenAI, Anthropic (Claude), or any local model via Ollama.
Why this exists?
Localizing Android apps usually involves paying for services, exporting CSVs, or manually using Google Translate. This tool translates strings.xml directly in your project using modern LLMs, giving significantly better context-aware translations.
Zero dependencies — no pip install of extra libraries required. Uses only Python's built-in networking.
Installation
pip install android-localisation
To update to the latest version:
pip install --upgrade android-localisation
Quick Start
# 1. Translate (Gemini free tier recommended)
android-localise translate --api-key YOUR_GEMINI_API_KEY
# 2. Fix any XML escaping issues introduced by the LLM
android-localise fix
# 3. Verify no format specifiers were corrupted (requires Java JDK)
android-localise verify
The Three Commands
1. translate — Translate strings into all locale directories
Reads app/src/main/res/values/strings.xml (English) and writes translated strings.xml into every values-* directory it finds.
Prerequisites:
- Create empty
values-<lang>/folders for each language you want (e.g.values-hi/,values-es/) - Get an API key — Google Gemini AI Studio has a generous free tier
# Basic — Gemini (default)
android-localise translate --api-key YOUR_GEMINI_API_KEY
# With app context for better translations
android-localise translate --api-key YOUR_KEY --app-context "a fitness tracking app"
# OpenAI
android-localise translate --api-key YOUR_KEY --provider openai --model gpt-4o
# Anthropic (Claude)
android-localise translate --api-key YOUR_KEY --provider anthropic
# Local model via Ollama
android-localise translate --provider custom --base-url http://localhost:11434/v1/chat/completions --model llama3
Full arguments:
| Argument | Description | Default |
|---|---|---|
--api-key |
API key (or set GEMINI_API_KEY, OPENAI_API_KEY, ANTHROPIC_API_KEY env vars) |
None |
--provider |
AI provider: gemini, openai, anthropic, custom |
gemini |
--model |
Model name (e.g. gemini-2.5-flash, gpt-4o, claude-3-5-sonnet-latest) |
provider default |
--app-context |
Short description of your app to improve translation quality | None |
--res-dir |
Path to the Android res/ directory |
app/src/main/res |
--base-url |
Base URL for custom OpenAI-compatible endpoints | None |
--sleep |
Seconds between requests to avoid rate limits | 5.0 |
2. fix — Fix XML escaping issues
LLMs occasionally introduce malformed characters — curly apostrophes ('), unescaped quotes, or broken % symbols. This command cleans them all up.
android-localise fix
# or with a custom res dir:
android-localise fix --res-dir path/to/res
3. verify — Catch format specifier crashes before they happen
LLMs can corrupt Android format specifiers like %1$s or %d, which causes UnknownFormatConversionException crashes at runtime. This command compiles a Java verifier and dry-runs String.format() against every translated string.
android-localise verify
Requires javac in your system PATH. Run from Android Studio's terminal if needed.
Recommended Workflow
- Update your English
strings.xml - Create empty
values-<lang>/folders for the languages you want android-localise translate --api-key YOUR_KEYandroid-localise fixandroid-localise verify- Build and test your app
Supported Providers
| Provider | Default Model | API Key Env Var |
|---|---|---|
gemini (default) |
gemini-2.5-flash |
GEMINI_API_KEY |
openai |
gpt-4o-mini |
OPENAI_API_KEY |
anthropic |
claude-3-5-sonnet-latest |
ANTHROPIC_API_KEY |
custom |
(must specify) | OPENAI_API_KEY or none |
Contributing
Issues and PRs welcome at github.com/BharathKmalviya/android-llm-localization.
Releases are fully automated — bumping the version in pyproject.toml and pushing to master triggers a build and publish to PyPI automatically.
Created to make Android localization accessible, free, and completely automated.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file android_localisation-1.0.1.tar.gz.
File metadata
- Download URL: android_localisation-1.0.1.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8746e9dcc01b948b263d26070fdc031139005cb71f9c27c74c58f9a53b7179f3
|
|
| MD5 |
49fee74f971d654dc692c4dc2109424c
|
|
| BLAKE2b-256 |
3482a9410393f731598de60d2aa7cd4ad9b5e370566eaa8c06f953ddadc14648
|
Provenance
The following attestation bundles were made for android_localisation-1.0.1.tar.gz:
Publisher:
publish.yml on BharathKmalviya/android-llm-localization
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
android_localisation-1.0.1.tar.gz -
Subject digest:
8746e9dcc01b948b263d26070fdc031139005cb71f9c27c74c58f9a53b7179f3 - Sigstore transparency entry: 1059760558
- Sigstore integration time:
-
Permalink:
BharathKmalviya/android-llm-localization@237eb456f665b896587dddd71e76fa37adb9731b -
Branch / Tag:
refs/heads/master - Owner: https://github.com/BharathKmalviya
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@237eb456f665b896587dddd71e76fa37adb9731b -
Trigger Event:
push
-
Statement type:
File details
Details for the file android_localisation-1.0.1-py3-none-any.whl.
File metadata
- Download URL: android_localisation-1.0.1-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91ccf97b15ed2af8c2a2e00724f1a586e9f668ef13305938199fe5d0b37b7f01
|
|
| MD5 |
e9aa992204515b36377de00180e5f03e
|
|
| BLAKE2b-256 |
94b4f991f27c23735848f9402717e65758c967e3c5a58da300120965ee87c260
|
Provenance
The following attestation bundles were made for android_localisation-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on BharathKmalviya/android-llm-localization
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
android_localisation-1.0.1-py3-none-any.whl -
Subject digest:
91ccf97b15ed2af8c2a2e00724f1a586e9f668ef13305938199fe5d0b37b7f01 - Sigstore transparency entry: 1059760568
- Sigstore integration time:
-
Permalink:
BharathKmalviya/android-llm-localization@237eb456f665b896587dddd71e76fa37adb9731b -
Branch / Tag:
refs/heads/master - Owner: https://github.com/BharathKmalviya
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@237eb456f665b896587dddd71e76fa37adb9731b -
Trigger Event:
push
-
Statement type: