Download the PHP package sirgrimorum/transarticles without Composer
On this page you can find all versions of the php package sirgrimorum/transarticles. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sirgrimorum/transarticles
More information about sirgrimorum/transarticles
Files in sirgrimorum/transarticles
Package transarticles
Short Description Localization using db table as source for translated text
License MIT
Homepage http://desarrollo.grimorum.com/andres/transarticles
Informations about the package transarticles
TransArticles
Database-backed multilingual content for Laravel. Store rich-text articles in the database instead of flat files, retrieve them by locale, expose them to JavaScript, and manage them via the CrudGenerator admin — all with a single helper call.
Features
- Database-backed translations — articles stored per locale in the
articlestable - Automatic locale fallback — returns any available language when the current locale is missing
- Dot-notation keys —
scope.nicknameaddressing (e.g.help.contact_us) - JavaScript exposure — publish a whole scope of articles to a JS global for frontend use
- Blade directives — render or expose articles without leaving the template
trans_article()helper — global function usable anywhere in PHP- Seeder generation — dump the current
articlestable to a seed file with one command - CrudGenerator integration — articles can be managed via the CrudGenerator admin when both packages are installed
Requirements
- PHP >= 8.2
- Laravel >= 9.0
Installation
Run migrations
This creates the articles table with columns: id, nickname, scope, lang, content, activated, user_id.
Publish configuration (optional)
Publishes config/sirgrimorum/transarticles.php.
Configuration
config/sirgrimorum/transarticles.php
Creating Articles
Insert records directly or use the CrudGenerator admin (if installed):
Retrieving Articles
Facade
Helper function
Blade directives
JavaScript usage (after @transarticles_tojs)
Locale Fallback Behaviour
- Look for an article with
lang = App::getLocale()andactivated = true - If not found, return any activated article for that
scope.nickname - If still not found, return the nickname itself (useful for spotting missing articles)
A warning label is shown when content is returned in a fallback language.
Artisan Commands
transarticles:createseed
Generates a database seed file from the current articles table:
The generated seed file is placed in database/seeds/ (or database/seeders/ for Laravel 8+).
API Reference
TransArticles::get()
Returns the HTML content of the article identified by scope.nickname for the current locale.
TransArticles::getjs()
Returns a <script> tag that assigns all articles in the scope to window.{basevar}.{scope}.
trans_article()
Global helper — equivalent to TransArticles::get($nickname).
Blade directive — @transarticles
Blade directive — @transarticles_tojs
License
The MIT License (MIT). See LICENSE.md.