AI Agent (LoxiBot)
Overview
SDK 1.2.0+ includes the built-in LoxiBot AI Agent, providing intelligent translation review and version publishing capabilities. Integrators can manually control the floating button and trigger the review process via SDK methods.
Floating Button Control
Manually show or hide the LoxiBot floating button:
// Show LoxiBot floating button
LoxilyLocalize.showAgentBubble();
// Hide LoxiBot floating button
LoxilyLocalize.hideAgentBubble();Tapping the floating button automatically captures a screenshot of the current screen and opens the LoxiBot chat interface for AI translation review.
Programmatic Review (Recommended)
In addition to the floating button, the SDK provides the reviewCurrentScreen() method, allowing integrators to trigger the review process from their own UI:
Option 1: OCR Recognition (without string_id)
// Automatically captures a screenshot; AI uses OCR to recognize on-screen text and match string_ids
LoxilyLocalize.reviewCurrentScreen();Option 2: Exact Matching (with string_id array, recommended)
// Pass the string_id list used on the current screen for exact translation matching
String[] stringIds = {"home.title", "home.subtitle", "home.welcome_msg"};
LoxilyLocalize.reviewCurrentScreen(stringIds);Advantages of passing string_ids:
- Avoids inaccurate OCR text recognition
- Resolves ambiguity when different string_ids share the same display text (e.g., multiple "Confirm" buttons with different string_ids)
- SDK automatically queries the backend for each string_id's source text and all language translations, providing AI with precise data
- Unmatched string_ids are flagged as "needs attention", helping discover missing translations
Option 3: External Screenshot (recommended for game engines)1.3.3+
For Unity, Unreal, Cocos2dx, and other game engines — the game captures its own screenshot via RenderTexture and passes the image byte[] to the SDK.
// Game engine captures screenshot, passes PNG/JPEG byte[] to SDK
byte[] screenshotBytes = ...; // From RenderTexture
String[] stringIds = {"dialog.npc_greeting", "dialog.player_choice_1"};
LoxilyLocalize.reviewCurrentScreen(stringIds, screenshotBytes);Unity C# Example:
// 1. Capture screenshot via RenderTexture
RenderTexture rt = new RenderTexture(Screen.width, Screen.height, 24);
Camera.main.targetTexture = rt;
Camera.main.Render();
RenderTexture.active = rt;
Texture2D tex = new Texture2D(rt.width, rt.height, TextureFormat.RGB24, false);
tex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
tex.Apply();
byte[] pngBytes = tex.EncodeToPNG();
Camera.main.targetTexture = null;
RenderTexture.active = null;
// 2. Call SDK
AndroidJavaClass sdk = new AndroidJavaClass("net.ilocalize.init.LoxilyLocalize");
sdk.CallStatic("reviewCurrentScreen", stringIds, pngBytes);Advantages of external screenshot mode:
- No
FOREGROUND_SERVICE_MEDIA_PROJECTIONpermission required, avoiding Google Play review issues - Game engines can precisely capture rendered content (including GL/Vulkan) via RenderTexture
- SDK skips internal screenshot logic and directly uses the externally provided image
Note: When
imageBytesis provided, the SDK does not perform any system screenshot operations (no PixelCopy or MediaProjection), giving integrators full control over the screenshot source.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| stringIds | String[] | No | Array of string_ids used on the current screen; pass null for OCR recognition |
| imageBytes | byte[] | Yes | PNG or JPEG screenshot data |
How It Works
When stringIds are provided, the SDK will:
- Capture a screenshot of the current screen (or use the externally provided screenshot)
- Immediately open the LoxiBot chat interface (showing loading state)
- Asynchronously call the backend API to batch-query complete translation data for each string_id (source text + all language translations)
- Once complete, send the precise mapping as context to the AI Agent
- AI Agent analyzes translation quality based on the screenshot + precise string_id mapping (skipping OCR)
Workflow
- Trigger Review → Call
reviewCurrentScreen()or tap the floating button to capture a screenshot and open the LoxiBot chat interface - AI Analysis → LoxiBot analyzes translation quality based on the screenshot and string_id mapping (or OCR recognition)
- Translation Review → Displays translation optimization suggestion cards, supporting individual or batch optimization
- Publish Version → After optimization, a version publish form appears automatically; select environment and version range, then publish with one click
- Real-time Status → The publish card polls and displays publishing progress in real-time until completion
AI Agent Feature List
| Feature | Description |
|---|---|
| Page Text AI Optimization | Screenshot + string_id exact matching (or OCR) → match entries → generate optimization suggestions |
| Individual Optimization | Optimize a single translation entry |
| Batch Optimization | Optimize all AI-suggested translations at once |
| Version Publishing | Select publish environment (testing/production) and version range, publish with one click |
| Publish Status Tracking | Real-time polling showing publish progress (initiated → in progress → completed) |
| Real-time Thinking Display | Shows AI's reasoning process, expandable/collapsible |