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:
- Rodrigo Aguilera (rodrigoaguilera) - https://www.drupal.org/u/rodrigoaguilera
Supporting organizations:
Initial development
Project information
- Project categories: Multilingual
- Created by rodrigoaguilera on , updated
Stable releases for this project are covered by the security advisory policy.
Look for the shield icon below.
