Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Signals

A list of the Transloco Signal-based API methods and their usages

translateSignal

Gets the translated value of a key as a Signal.

import { translateSignal } from '@jsverse/transloco';

// Basic usage
text = translateSignal('hello');

// Translating multiple keys
textList = translateSignal(['green', 'blue']);

// With parameters
textVar = translateSignal('hello', { variable: 'world' });

// With specific language
textSpanish = translateSignal('hello', { variable: 'world' }, 'es');

// With scope
textTodosScope = translateSignal('hello', { variable: 'world' }, { scope: 'todos' });

// With dynamic signals
dynamicKey = signal('hello');
dynamicParam = signal({ variable: 'world' });
text = translateSignal(this.dynamicKey, this.dynamicParam);

translateObjectSignal

Gets the translated object of a key as a Signal.

activeLang

TranslocoService exposes the currently active language as a signal, so you can derive from it without subscribing to langChanges$.

The signal always holds a value — it is initialised synchronously with the active language — so there is no undefined to guard against.

Integration with Angular Dependency Injection

Both translateSignal and translateObjectSignal integrate with Angular's dependency injection system. They can be called within an injection context or with an explicitly provided injector.

When no injector is provided, the functions automatically assert that they are being called within an injection context and use the current injector.

Last updated

Was this helpful?