agency-orgo / string-translations
A Statamic addon for managing string translations
Package info
github.com/agency-orgo/string-translations
pkg:composer/agency-orgo/string-translations
Requires
- php: ^8.3
- statamic/cms: ^6.0
Requires (Dev)
- orchestra/testbench: ^10.0
- phpunit/phpunit: ^12.3
README
A Statamic addon for managing string translations with database storage and fallback support.
Features
- Database-driven string translations
- Multi-language support with fallback hierarchy
- Bulk operations for performance
- Search and filter functionality
- Control Panel integration
- REST API and GraphQL support
Installation
You can install this addon via Composer:
composer require agency-orgo/string-translations
Usage
After installation, you'll find "String Translations" in your Statamic Control Panel under Utilities.
Configuration
Publish the config file:
php artisan vendor:publish --tag=string-translations-config
return [ 'database' => [ 'connection' => env('STRING_TRANSLATIONS_DB_CONNECTION', 'default'), 'table' => env('STRING_TRANSLATIONS_TABLE', 'localized_strings'), ], 'api' => [ 'enabled' => env('STRING_TRANSLATIONS_API_ENABLED', false), ], ];
REST API
Enable with STRING_TRANSLATIONS_API_ENABLED=true in your .env.
Fetch translations:
curl "https://your-site.com/!/string-translations/strings?lang=en"
Create keys:
curl -X POST "https://your-site.com/!/string-translations/strings" \ -H "Content-Type: application/json" \ -d '{"keys": ["nav.home", "nav.about"]}'
GraphQL
Automatically available when Statamic's GraphQL is enabled (STATAMIC_GRAPHQL_ENABLED=true). No additional configuration needed.
Fetch translations
{
string_translations(lang: "en") {
lang
strings
}
}
Response:
{
"data": {
"string_translations": {
"lang": "en",
"strings": {
"nav.home": "Home",
"welcome.message": "Welcome!"
}
}
}
}
Create translation keys
Creates keys across all configured sites with an untranslated_ prefix.
mutation { createStringTranslations(keys: ["nav.contact", "footer.copyright"]) { created } }
Response:
{
"data": {
"createStringTranslations": {
"created": 12
}
}
}
The created count reflects total rows inserted (keys * sites). Duplicate keys are ignored.
Requirements
- Statamic 6.0+
- PHP 8.3+