Skip to content

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:

java
// 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.

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)

java
// Automatically captures a screenshot; AI uses OCR to recognize on-screen text and match string_ids
LoxilyLocalize.reviewCurrentScreen();
java
// 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

For Unity, Unreal, Cocos2dx, and other game engines — the game captures its own screenshot via RenderTexture and passes the image byte[] to the SDK.

java
// 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:

csharp
// 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_PROJECTION permission 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 imageBytes is provided, the SDK does not perform any system screenshot operations (no PixelCopy or MediaProjection), giving integrators full control over the screenshot source.

Parameters

ParameterTypeRequiredDescription
stringIdsString[]NoArray of string_ids used on the current screen; pass null for OCR recognition
imageBytesbyte[]YesPNG or JPEG screenshot data

How It Works

When stringIds are provided, the SDK will:

  1. Capture a screenshot of the current screen (or use the externally provided screenshot)
  2. Immediately open the LoxiBot chat interface (showing loading state)
  3. Asynchronously call the backend API to batch-query complete translation data for each string_id (source text + all language translations)
  4. Once complete, send the precise mapping as context to the AI Agent
  5. AI Agent analyzes translation quality based on the screenshot + precise string_id mapping (skipping OCR)

Workflow

  1. Trigger Review → Call reviewCurrentScreen() or tap the floating button to capture a screenshot and open the LoxiBot chat interface
  2. AI Analysis → LoxiBot analyzes translation quality based on the screenshot and string_id mapping (or OCR recognition)
  3. Translation Review → Displays translation optimization suggestion cards, supporting individual or batch optimization
  4. Publish Version → After optimization, a version publish form appears automatically; select environment and version range, then publish with one click
  5. Real-time Status → The publish card polls and displays publishing progress in real-time until completion

AI Agent Feature List

FeatureDescription
Page Text AI OptimizationScreenshot + string_id exact matching (or OCR) → match entries → generate optimization suggestions
Individual OptimizationOptimize a single translation entry
Batch OptimizationOptimize all AI-suggested translations at once
Version PublishingSelect publish environment (testing/production) and version range, publish with one click
Publish Status TrackingReal-time polling showing publish progress (initiated → in progress → completed)
Real-time Thinking DisplayShows AI's reasoning process, expandable/collapsible