RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

Server CommandsGE UtilitiesGame Engine MainNavigation GraphScreenshot CaptureServerServer ConnectionSpawnpoint ManagerSimulation TimeVehicle SpawningSuspension Frequency Tester
Ambient SoundUI Apps ManagerUI AudioBindings LegendCamera Distance AppDeveloper ConsoleCredits MusicExternal WebSocket ServerFade ScreenGame BlurGameplay App ContainersGrid SelectorLivery EditorMessages DebuggerMessages/Tasks App ContainersMission InfoPolice InfoTop BarUI ModsNavigation Map DataVehicle Paint EditorVehicle Vicinity AppUI Visibility
Button ModuleDisplay Data ModuleFilter ModuleTiles ModuleTranslate Helper

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferenceGE ExtensionsuigridSelectorUtils

Translate Helper

Translation utility with caching and nested translation pattern resolution.

Translation utility with caching and nested translation pattern resolution.


Overview

translateHelper wraps the engine's translateLanguage function with a cache layer and handles nested translation patterns commonly found in BeamNG content strings.

Module path: lua/ge/extensions/ui/gridSelectorUtils/translateHelper.lua (loaded via require)


Exports (M)

FunctionSignatureDescription
translate(key)Translates a key, resolves nested patterns, caches results.

Internals

Basic Translation

local function translate(key)
  if not key or type(key) ~= "string" then
    return key or "Missing Translation Key!"
  end
  if translateCache[key] then return translateCache[key] end
  local translated = translateLanguage(key, key, true)
  translated = processNestedTranslations(translated)
  translateCache[key] = translated
  return translated
end

Nested Translation Patterns

Handles Angular-style patterns found in BeamNG translation strings:

PatternExampleBehavior
{{ 'key' | translate}}{{ 'ui.menu.title' | translate}}Quoted key with pipe
{{:: 'key' | translate}}{{:: 'ui.label' | translate}}One-time binding syntax
{{ key | translate}}{{ ui.button | translate}}Unquoted key with pipe
{{key}}{{ui.name}}Simple variable substitution

Recursive Resolution

Nested patterns are resolved iteratively (up to 10 iterations) to handle translations that contain further translation keys:

local changed = true
local iterations = 0
while changed and iterations < maxIterations do
  changed = false
  iterations = iterations + 1
  -- Process each pattern type...
end

Caching

Results are cached in translateCache keyed by the original input string. The cache persists for the module's lifetime.

Usage in Grid Selectors

local translate = require("ge/extensions/ui/gridSelectorUtils/translateHelper").translate

-- Translate item names
item.name = translate(campaign.title)
item.level = translate(core_levels.getLevelTitle(item.level))

-- Translate specification labels
{label = translate("ui.common.property.difficulty"), value = translate(difficultyValue)}

How It Works

  1. Caller passes a translation key (e.g., "ui.menu.start")
  2. Cache is checked first for instant return
  3. translateLanguage(key, key, true) queries the engine's localization system
  4. Result is scanned for nested {{ ... | translate}} patterns
  5. Each nested pattern is recursively translated (up to 10 iterations)
  6. Final result is cached and returned

Additional Exports

The following exports are available but not yet documented in detail:

  • M.translate

See Also

  • Button Module - Related reference
  • Display Data Module - Related reference
  • Filter Module - Related reference
  • UI System Guide - Guide

Tiles Module

Generic tile processing framework for grid selectors - provides path routing, grouping, clustering, and special group handling.

Camera Management

Camera management for the livery editor - orthographic views, orbit camera, and layer-based positioning.

On this page

OverviewExports (M)InternalsBasic TranslationNested Translation PatternsRecursive ResolutionCachingUsage in Grid SelectorsHow It WorksAdditional ExportsSee Also