This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
You can install the package via composer:
composer require dinhdjj/laravel-js-localization
This package minify step to usage. You just add directive @jslocalization
to blade layout.
<!-- resources/view/app.blade.com -->
<!DOCTYPE html>
<html>
<head>
@jslocalization
<!-- other js -->
</head>
<body class="font-sans antialiased">
<!-- -->
</body>
</html>
And you must remember that when you update this package or update lang files. You should run below command to make it effect
php artisan view:cache
If you use typescript below lines will help you
type Trans = (key: string, replaces?: Record<string,string>, local?: string|null) => string;
type TransChoice = (key: string, number: number, replaces?: Record<string,string>, local?: string|null) => string;
declare global {
interface Window {
__: Trans;
trans: Trans;
transChoice: TransChoice;
}
}
Finally usage in real life
window.trans('hello :name', {name: 'dinhdjj'});
window.__('hello :name', {name: 'dinhdjj'});
window.transChoice('hello :name|xin chao :name', 1,{name: 'dinhdjj'});
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.