在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):Astrotomic/laravel-translatable开源软件地址(OpenSource Url):https://github.com/Astrotomic/laravel-translatable开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):IntroductionIf you want to store translations of your models into the database, this package is for you. This is a Laravel package for translatable models. Its goal is to remove the complexity in retrieving and storing multilingual model instances. With this package you write less code, as the translations are being fetched/saved when you fetch/save your instance. The full documentation can be found at GitBook. Installationcomposer require astrotomic/laravel-translatable Quick ExampleGetting translated attributes$post = Post::first();
echo $post->translate('en')->title; // My first post
App::setLocale('en');
echo $post->title; // My first post
App::setLocale('de');
echo $post->title; // Mein erster Post Saving translated attributes$post = Post::first();
echo $post->translate('en')->title; // My first post
$post->translate('en')->title = 'My cool post';
$post->save();
$post = Post::first();
echo $post->translate('en')->title; // My cool post Filling multiple translations$data = [
'author' => 'Gummibeer',
'en' => ['title' => 'My first post'],
'fr' => ['title' => 'Mon premier post'],
];
$post = Post::create($data);
echo $post->translate('fr')->title; // Mon premier post Tutorials
ChangelogPlease see CHANGELOG for more information on what has changed recently. ContributingPlease see CONTRIBUTING for details. You could also be interested in CODE OF CONDUCT. SecurityIf you discover any security related issues, please check SECURITY for steps to report it. Credits
Versions
TreewareYou're free to use this package, but if it makes it to your production environment I would highly appreciate you buying the world a tree. It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to plant trees. If you contribute to my forest you’ll be creating employment for local families and restoring wildlife habitats. You can buy trees at offset.earth/treeware Read more about Treeware at treeware.earth |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论