Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Multilingual state

Security covered Under active development

This module provides a way to store and retrieve values that vary based on language, without needing to create separate content entities. It extends Drupal's State API to allow for language-specific settings that can be managed programmatically.

INTRODUCTION

Wrapper for State API that handles states that variate per language.

The primary use case for this module is to store translatable variables without a content entity.

REQUIREMENTS

More than one language enabled.

CONFIGURATION

None, API-only module.

USAGE

Defines a new service multilingual_state that follows the same interface as the Drupal State service but gets/sets the variable with a language suffix.

When the current language is Spanish something like this can be executed:

\Drupal::service('multilingual_state')->set('site_title', 'Mi Drupal en español');
\Drupal::service('multilingual_state')->get('site_title');

And that variable can be different for each language.

There is three new methods:

// Specify the langcode explictly.
public function getTranslated($key, $langcode, $default = NULL);
public function setTranslated($key, $value, $langcode);

// Remove the variable from all languages.
public function deleteAllLanguages($key);

MAINTAINERS

Current maintainers for Drupal 11:

Drupal 10–11

Ask your assistant about Multilingual state

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

  • language Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Oct 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Dormant

Releases

Version Type Core PHP Release date
1.0.0 Stable 10–11 Oct 30, 2024
1.x-dev Dev 11 Oct 30, 2024