static_label
Overview
The Static Label module (machine name: static_label) provides a custom content entity to manage static labels as key → value pairs in Drupal.
It is designed especially for headless and decoupled architectures, where frontend applications (such as React, Angular, Flutter, etc.) need configurable, multilingual static text that can be managed centrally in Drupal and exposed via an API.
This allows frontend teams to update labels without changing frontend code, while fully leveraging Drupal’s content and translation capabilities.
The module also includes an optional REST API submodule (static_label_rest_api) to expose these labels programmatically.
Module Structure
- static_label
- static_label_rest_api
Base module that defines the Static Label entity and UI.
Submodule that exposes Static Labels via a REST endpoint.
Key Features
- Manage key → value static labels
- Supports multilingual translations
- Drupal admin UI for CRUD operations
- Designed for headless / decoupled frontends
- Optional REST API for frontend consumption
Use Cases
- Centralized management of frontend UI labels
- Error messages, form labels, helper texts
- Multilingual frontend applications
- Avoid hardcoding labels in frontend code
- Reuse the same labels across web and mobile apps
Configuration
Manage Static Labels
After enabling the base module:
- Navigate to
- You can:
Content → Static Labels
(/admin/content/static-labels)
- Add new static labels
- Edit or delete existing labels
- Translate labels (if multilingual is enabled)
Enable Multilingual Support
To enable translations for Static Labels:
- Go to
- Enable translations for the Static Label entity
- Configure the required languages
/admin/config/regional/content-language
Example Usage
Create a Static Label
- Go to
- Click Add Static Label
- Enter:
/admin/content/static-labels
- Key (unique machine name, e.g. lbl_firstname)
- Label (e.g. Enter the first name)
- Save the label
REST API Submodule (static_label_rest_api)
Overview
The Static Label REST API submodule exposes static labels via a REST endpoint, making them easily consumable by frontend applications.
This submodule depends on:
- static_label
- rest
- serialization
REST Endpoint
GET /api/v1/static-labels
Optional Query Parameters
Parameter
key - Fetch a specific label by machine name
lang - Language code (e.g. en, fr)
/api/v1/static-labels?key=lbl_firstname
/api/v1/static-labels?lang=taSample API Output
{
"meta": {
"count": 3,
"lang": "en"
},
"data": {
"lbl_firstname": "Enter the first name",
"lbl_password": "Enter the password",
"err_msg_password": "Please enter the valid password!"
}
}REST Configuration
The REST resource configuration is automatically managed by the submodule.
- Config is installed from config/install
- Config is automatically removed on module uninstall
- No manual cleanup required
Frontend Usage (Headless CMS)
In a headless Drupal setup, frontend applications can fetch static labels from Drupal and render them dynamically.
Benefits
- Update labels anytime from Drupal
- No frontend redeployment required
- Multilingual support out of the box
- Consistent content across platforms
Supported Frontends
- React
- Angular
- Flutter , etc
- Any framework capable of consuming JSON APIs
Installation
Troubleshooting
- Clear caches after installing or updating modules
- Ensure multilingual settings are enabled for translations
- Ensure REST and serialization modules are enabled when using the API
- Verify REST resource configuration at
/admin/config/services/rest
Maintainer
Mamallan A
https://www.drupal.org/u/mamallana
Support
For bug reports, feature requests, and general support, use the issue queue: