Osy#betaRun it on Osyrin: osyrin.com

Kits · AI models

Machine translation

Language detection that works offline (scripts, and the commonest words of twelve European languages) and translation through the app's own model — glossary terms kept as written, a missing key a state rather than an error.

Package
Osysharp.MachineTranslation
Install
use Osysharp.MachineTranslation@0;
Group
AI models
Tests
15 in the kit’s own suite
Builds on
—
Used by
Conversations in every language

Which language is this — and what does it say in mine? Language detection that works offline, and translation through your app's own model.

Use it

osy

app Guide {
  use Osysharp.MachineTranslation@0;
  model "model/**/*.osy";
}

osy

using Osysharp.MachineTranslation;

var t = new ModelTranslator { KeySecret = "ModelKey" };
var language = t.Detect("Hej! Jag har inte fått min bokning.");               // "sv" — no call
var english  = t.Translate(text, language, "en", [new TranslationTerm { Term = "Wanderly" }]);

Your provider, your key

Nothing is provided. Translation runs on the model you choose — any provider your app allows (app.Models, app.DefaultModel) — with your key, which you give your app as a secret. Until the key has a value, IsReady() is false: detection still works offline, nothing is sent anywhere, and every caller keeps the original text.

What it does

Detection, offlineLanguageDetector tells a text by its script — Arabic, Persian, Cyrillic, Greek, Hebrew, Devanagari, Thai, Japanese, Korean, Chinese — or by the commonest words and letters of twelve European languages. Free, instant and the same on every machine. It says when it is not sure
The model only when neededModelTranslator.Detect asks the model only when a text is too short or too mixed to tell, and uses its answer only when it is a language tag
Translation through your modelone plain call through LlmClient.Complete — your key, your router, your budget. No tools, no memory: the text is treated as text, never as instructions
Terms keptnames and product terms stay as written, or are written the way you say
Long textssent a paragraph at a time past MaxChunk
Same language, no call"en-GB" into "en" is the text itself
Not ready is a statewith no key, IsReady() is false and NotReadyReason() says which secret to set — a caller keeps the original instead of failing
Your languagesadd a LanguageProfile and the detector knows one more

Testing with it

No test should call a real model. Answer for it with LlmClient.Complete.Stub(prompt => …), and make the translator ready with ModelKeyIsSet.Stub(name => true).

Its tests

Detection across eighteen languages, the not-sure cases, a language an app adds, the prompt a translation sends and the calls it never makes — every one with the model stubbed.

Get it

Add the kit to your app’s manifest:

osy

app MyApp {
  use Osysharp.MachineTranslation@0;
}

Then run osy lock: it downloads the release, verifies it by its content address and pins that version in osyrin.lock. osy kits Osysharp.MachineTranslation shows what the kit is for, from inside your app.

Reference: osy docs ui-machine-translation-kit.