Translate, detranslate, and mix loaded language modules from one shell without losing the line between the framing, controls, and active work area.
Drag modules or transformers to reorder the translation pipeline. Modules apply in top-to-bottom order.
Replaces this page's settings and presets with the ones saved at the old address in this browser. Custom modules are added, never removed.
Welcome to the custom module creation guide! This guide will walk you through creating your own translation modules for the Saria Translator system.
A module is a self-contained unit that applies linguistic transformations to text. Each module can define:
The Saria Translator is designed for constructed languages (conlangs) and linguistic transformations. Modules can:
A custom module ZIP must contain at minimum:
| File | Purpose | Required? |
|---|---|---|
module.js |
Main module definition and exports | ✅ Yes |
data.js |
Linguistic data (lexicon, rules, etc.) | ⚠️ Recommended |
transformer_*.js |
Individual transformation functions | ⚠️ As needed |
Here's the basic structure of a module.js file:
export const MyModule = {
// Unique identifier (lowercase, no spaces)
id: "mymodule",
// Display name
name: "My Custom Module",
// Version string
version: "1.0.0",
// Description shown in UI
description: "Brief description of what this module does",
// Optional: author information
author: "Your Name",
// Optional: default enabled state
enabled: true,
// Sliders for user control
sliders: [
{
id: "mymoduleIntensity", // Must be unique across all modules
label: "Intensity",
defaultValue: 50,
min: 0,
max: 100,
hint: "Controls how strongly transformations are applied"
}
],
// Optional: flags for boolean toggles
flags: [
{
id: "mymoduleSpecialMode",
label: "Enable Special Mode",
defaultValue: false
}
],
// Optional: mood sliders (normalized 0-1, sum to 1.0)
moods: [],
// Transformers (the core transformation pipeline)
transformers: [
{
id: "phonology",
name: "Phonology",
apply: (text, context, steps, tokenMap) => {
// Your transformation logic here
return text;
}
}
]
};
mymoduleIntensity) to avoid conflicts with other modules.
If you have separate files, use ES6 imports:
// In module.js
import { applyPhonology } from './phonology.js';
import { applyLexicon } from './lexicon.js';
import { MY_LEXICON_DATA } from './data.js';
export const MyModule = {
// ... module definition
};
A transformer is a function that takes text and returns modified text. Each transformer receives four parameters:
(text, context, steps, tokenMap) => {
// Your transformation logic
return modifiedText;
}
| Parameter | Type | Description |
|---|---|---|
text |
string | The input text to transform |
context |
object | Contains sliders, flags, and moods values |
steps |
array | Debug array to track transformations |
tokenMap |
Map | Tracks word-level transformations for Rule Inspector |
The context object provides access to all module controls:
{
sliders: {
mymoduleIntensity: 0.5, // Normalized 0-1 from UI 0-100
mymoduleLexicon: 0.8,
// ... all other module sliders
},
flags: {
mymoduleSpecialMode: true,
// ... all flags
},
moods: {
fear: 0.25,
comfort: 0.25,
// ... normalized moods (sum = 1.0)
}
}
Replace specific patterns in the text:
apply: (text, context, steps, tokenMap) => {
let result = text;
// Check slider value
const intensity = context.sliders.mymoduleIntensity;
// Apply replacement
result = result.replace(/pattern/gi, 'replacement');
// Track step for debugging
steps.push({
label: "My Transformation",
preview: result
});
return result;
}
Process each word individually for lexical replacements:
import { LEXICON } from './data.js';
apply: (text, context, steps, tokenMap) => {
const intensity = context.sliders.mymoduleLexicon;
if (intensity < 0.2) return text; // Skip if too low
// Split preserving whitespace
const tokens = text.split(/(\s+)/);
const result = tokens.map(token => {
// Extract word and punctuation
const match = token.match(/^([A-Za-z']+)([?.!,;:]*)$/);
if (!match) return token;
const [, word, punct] = match;
const lowerWord = word.toLowerCase();
// Check lexicon
if (LEXICON[lowerWord]) {
const replacement = LEXICON[lowerWord];
// Track transformation in tokenMap
if (!tokenMap.has(lowerWord)) {
tokenMap.set(lowerWord, []);
}
tokenMap.get(lowerWord).push({
module: "mymodule",
transformer: "lexicon",
rule: `${lowerWord} → ${replacement}`
});
return replacement + punct;
}
return token;
}).join('');
steps.push({
label: "Lexicon Replacement",
preview: result
});
return result;
}
Apply different transformations based on flags or mood:
apply: (text, context, steps, tokenMap) => {
let result = text;
// Check flag
if (context.flags.mymoduleSpecialMode) {
result = result.replace(/old/gi, 'new');
}
// Check mood (if applicable)
if (context.moods && context.moods.aggression > 0.5) {
result = result.toUpperCase();
}
steps.push({
label: "Conditional Transform",
preview: result
});
return result;
}
steps array so users can debug transformations with "Show transformation steps" enabled.
The band system provides progressive intensity control. Transformations become more aggressive as slider values increase through four levels:
| Band | Slider Range | Normalized (0-1) | Usage |
|---|---|---|---|
| 0 | 0-19% | 0.0-0.19 | Disabled - no transformations |
| 1 | 20-49% | 0.2-0.49 | Light - subtle transformations |
| 2 | 50-79% | 0.5-0.79 | Moderate - noticeable changes |
| 3 | 80-100% | 0.8-1.0 | Full - maximum transformations |
Instead of implementing band logic manually, import the shared band utility:
// Import from shared utilities (works for custom modules)
import { band } from '../shared/banding.js';
apply: (text, context, steps, tokenMap) => {
const intensity = context.sliders.mymoduleIntensity;
const b = band(intensity);
if (b === 0) return text; // Skip if disabled
let result = text;
// Band 1: Light transformations (20-49%)
if (b >= 1) {
result = result.replace(/th/gi, 'd');
}
// Band 2: Moderate transformations (50-79%)
if (b >= 2) {
result = result.replace(/sh/gi, 'sch');
}
// Band 3: Full transformations (80-100%)
if (b >= 3) {
result = result.replace(/w/gi, 'v');
}
steps.push({ label: "Phonology", preview: result });
return result;
}
If you can't import the helper, implement it manually:
function getBand(intensity) {
if (intensity < 0.2) return 0;
if (intensity < 0.5) return 1;
if (intensity < 0.8) return 2;
return 3;
}
For lexicon transformations, limit replacements by band:
const limits = [0, 1, 3, Infinity]; // Band 0, 1, 2, 3
const b = band(intensity);
const maxReplacements = limits[b];
let replacementCount = 0;
tokens.forEach(token => {
if (replacementCount >= maxReplacements) return;
if (LEXICON[token]) {
// Apply replacement
replacementCount++;
}
});
The tokenMap parameter is a Map that tracks word-level transformations for the Rule Inspector feature. Users can click words in the output to see which transformers modified them.
Each entry in the Map uses the transformed word (lowercase) as the key:
tokenMap.set("transformedword", {
original: "OriginalWord",
current: "transformedword",
transformations: [
{
module: "Module Display Name",
transformer: "transformer_id",
from: "before",
to: "after",
rule: "Human-readable description"
}
]
});
When a word is transformed, add an entry to tokenMap:
apply: (text, context, steps, tokenMap) => {
const tokens = text.split(/(\s+)/);
const result = tokens.map(token => {
const match = token.match(/^([A-Za-z']+)([?.!,;:]*)$/);
if (!match) return token;
const [, word, punct] = match;
const lowerWord = word.toLowerCase();
// Check for replacement
if (LEXICON[lowerWord]) {
const replacement = LEXICON[lowerWord];
const lowerReplacement = replacement.toLowerCase();
// Track in tokenMap (if it exists)
if (tokenMap) {
// Initialize entry if first transformation
if (!tokenMap.has(lowerReplacement)) {
tokenMap.set(lowerReplacement, {
original: word,
current: replacement,
transformations: []
});
}
// Add transformation record
tokenMap.get(lowerReplacement).transformations.push({
module: "My Module",
transformer: "lexicon",
from: lowerWord,
to: replacement,
rule: `${lowerWord} → ${replacement}`
});
}
return replacement + punct;
}
return token;
}).join('');
steps.push({ label: "Lexicon", preview: result });
return result;
}
if (tokenMap) before tracking (it may be undefined)module, transformer, from, to, and rule fieldsrule field should be human-readable for UI displayFor phonological transformations that change spelling:
apply: (text, context, steps, tokenMap) => {
const intensity = context.sliders.mymodulePhonology;
const b = band(intensity);
if (b === 0) return text;
let result = text;
const tokens = result.split(/(\s+)/);
const transformed = tokens.map(token => {
const match = token.match(/^([A-Za-z']+)([?.!,;:]*)$/);
if (!match) return token;
const [, word, punct] = match;
let modified = word;
// Band 1: TH → D
if (b >= 1 && /th/i.test(modified)) {
const before = modified;
modified = modified.replace(/th/gi, 'd');
// Track transformation
if (tokenMap && before !== modified) {
const key = modified.toLowerCase();
if (!tokenMap.has(key)) {
tokenMap.set(key, {
original: word,
current: modified,
transformations: []
});
}
tokenMap.get(key).transformations.push({
module: "My Module",
transformer: "phonology",
from: before,
to: modified,
rule: "TH → D (Germanic shift)"
});
}
}
return modified + punct;
}).join('');
steps.push({ label: "Phonology", preview: transformed });
return transformed;
}
Your module ZIP should be organized like this:
mymodule/
├── module.js # Main module definition (required)
├── data.js # Linguistic data exports (recommended)
├── phonology.js # Phonology transformer (if separate)
├── lexicon.js # Lexicon transformer (if separate)
└── README.md # Optional documentation
Before packaging, verify:
module.js exports a module object with id, name, versionmodule, transformer, from, to, rulesteps array for debugging./filename.js)mymodule-v1.0.zipmodule.js immediately, not a folder containing module.js.
| Issue | Cause | Solution |
|---|---|---|
| Module doesn't appear | ZIP structure incorrect | Ensure files are at root level in ZIP |
| Import errors in console | Relative paths wrong | Use ./filename.js for same directory |
| Sliders don't work | Slider ID conflicts | Prefix slider IDs with module name |
| Transformations not applied | Band check too restrictive | Verify if (b === 0) check, test at 50%+ |
saria_rules.js before packaging. This catches errors before upload.
A single-file module with progressive phonology transformations:
// module.js
export const FrenchAccentModule = {
id: "frenchaccent",
name: "French Accent",
version: "1.0.0",
description: "Applies French phonology patterns",
author: "Your Name",
sliders: [
{
id: "frenchaccentIntensity",
label: "Accent Strength",
defaultValue: 50,
min: 0,
max: 100,
hint: "Controls how strongly French phonology is applied"
}
],
transformers: [
{
id: "phonology",
name: "French Phonology",
apply: (text, context, steps, tokenMap) => {
const intensity = context.sliders.frenchaccentIntensity || 0;
// Band check
if (intensity < 0.2) return text;
let result = text;
// Band 1: Basic French sounds (20-49%)
if (intensity >= 0.2) {
result = result.replace(/\\bth/gi, 'z'); // "the" → "ze"
result = result.replace(/\\bh/gi, ''); // Drop H
}
// Band 2: More aggressive (50-79%)
if (intensity >= 0.5) {
result = result.replace(/w/gi, 'v'); // "water" → "vater"
result = result.replace(/ing\\b/gi, 'ain'); // "doing" → "doain"
}
// Band 3: Full Frenchification (80-100%)
if (intensity >= 0.8) {
result = result.replace(/er\\b/gi, 'é'); // "danger" → "dangé"
}
steps.push({
label: "French Phonology",
preview: result
});
return result;
}
}
]
};
module.js in a ZIP. This is the simplest possible custom module.
A more complex module with data separation:
// data.js
export const FANTASY_LEXICON_BAND1 = {
"magic": "mana",
"wizard": "mage",
"sword": "blade"
};
export const FANTASY_LEXICON_BAND2 = {
"power": "essence",
"strong": "mighty",
"weak": "feeble"
};
export const FANTASY_LEXICON_BAND3 = {
"friend": "companion",
"enemy": "foe",
"fight": "battle"
};
// lexicon.js
import {
FANTASY_LEXICON_BAND1,
FANTASY_LEXICON_BAND2,
FANTASY_LEXICON_BAND3
} from './data.js';
function getBand(intensity) {
if (intensity < 0.2) return 0;
if (intensity < 0.5) return 1;
if (intensity < 0.8) return 2;
return 3;
}
export function applyFantasyLexicon(text, intensity, steps, tokenMap) {
const b = getBand(intensity);
if (b === 0) return text;
// Combine lexicons based on band
let lexicon = { ...FANTASY_LEXICON_BAND1 };
if (b >= 2) Object.assign(lexicon, FANTASY_LEXICON_BAND2);
if (b >= 3) Object.assign(lexicon, FANTASY_LEXICON_BAND3);
// Split preserving whitespace
const tokens = text.split(/(\\s+)/);
const result = tokens.map(token => {
const match = token.match(/^([A-Za-z']+)([?.!,;:]*)$/);
if (!match) return token;
const [, word, punct] = match;
const lowerWord = word.toLowerCase();
if (lexicon[lowerWord]) {
const replacement = lexicon[lowerWord];
// Track in tokenMap
if (tokenMap) {
const key = replacement.toLowerCase();
if (!tokenMap.has(key)) {
tokenMap.set(key, {
original: word,
current: replacement,
transformations: []
});
}
tokenMap.get(key).transformations.push({
module: "Fantasy Lexicon",
transformer: "lexicon",
from: lowerWord,
to: replacement,
rule: `${lowerWord} → ${replacement}`
});
}
return replacement + punct;
}
return token;
}).join('');
steps.push({
label: "Fantasy Lexicon",
preview: result
});
return result;
}
// module.js
import { applyFantasyLexicon } from './lexicon.js';
export const FantasyLexiconModule = {
id: "fantasylexicon",
name: "Fantasy Lexicon",
version: "1.0.0",
description: "Replaces modern words with fantasy equivalents",
sliders: [
{
id: "fantasylexiconIntensity",
label: "Fantasy Level",
defaultValue: 50,
min: 0,
max: 100,
hint: "How much fantasy vocabulary to use"
}
],
transformers: [
{
id: "lexicon",
name: "Lexicon Replacement",
apply: (text, context, steps, tokenMap) => {
return applyFantasyLexicon(
text,
context.sliders.fantasylexiconIntensity,
steps,
tokenMap
);
}
}
]
};
module.js, lexicon.js, and data.js together in a ZIP.
A complex module with both phonology and lexicon transformers:
// module.js
export const ComplexModule = {
id: "complex",
name: "Complex Multi-Stage Module",
version: "1.0.0",
description: "Combines phonology and lexicon transformations",
sliders: [
{
id: "complexPhonology",
label: "Phonology Strength",
defaultValue: 50,
min: 0,
max: 100,
hint: "Controls sound changes"
},
{
id: "complexLexicon",
label: "Vocabulary Replacement",
defaultValue: 50,
min: 0,
max: 100,
hint: "Controls word replacements"
}
],
flags: [
{
id: "complexFormalMode",
label: "Formal Speech Mode",
defaultValue: false
}
],
transformers: [
// Phonology runs first
{
id: "phonology",
name: "Phonology",
apply: (text, context, steps, tokenMap) => {
const intensity = context.sliders.complexPhonology;
if (intensity < 0.2) return text;
let result = text.replace(/th/gi, 'd');
steps.push({ label: "Phonology", preview: result });
return result;
}
},
// Lexicon runs second
{
id: "lexicon",
name: "Lexicon",
apply: (text, context, steps, tokenMap) => {
const intensity = context.sliders.complexLexicon;
if (intensity < 0.2) return text;
// Check formal mode flag
const formal = context.flags.complexFormalMode;
let result = text;
if (formal) {
result = result.replace(/\\bhi\\b/gi, 'greetings');
} else {
result = result.replace(/\\bhello\\b/gi, 'hey');
}
steps.push({ label: "Lexicon", preview: result });
return result;
}
}
]
};
Use this prompt with AI coding assistants (like GitHub Copilot, Claude, ChatGPT) to create custom modules. Copy the prompt below and provide it to your LLM along with your linguistic requirements.