Multilingual state
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
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.