|
385 | 385 |
|
386 | 386 | ## <i class="fa-duotone fa-list-radio"></i> RTL support
|
387 | 387 |
|
388 |
| -Are you working on a website or application that supports <i class="fa-duotone fa-signs-post text-indigo-900 mr-1 fa-lg"></i> **right-to-left** languages like `Arabic` or `Hebrew` ? |
389 |
| - |
390 |
| -**<span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span>** makes it easy to incorporate right-to-left language support. |
| 388 | +**<span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span>** makes it easy to incorporate <i class="fa-duotone fa-signs-post text-indigo-900 mr-1 fa-lg"></i> **right-to-left** languages like `Arabic` or `Hebrew`. |
391 | 389 | it automatically detects the text direction and handles the necessary adjustments for you.
|
392 | 390 |
|
393 | 391 | Simply make sure the translation service is enabled and let **<span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span>** handle the rest.
|
394 | 392 |
|
395 | 393 | {% assign id = '# phpflasher rtl' %}
|
396 | 394 | {% assign type = 'success' %}
|
397 |
| -{% assign message = 'تم إرسال طلبك بنجاح.' %} |
398 |
| -{% assign title = 'نجاح' %} |
| 395 | +{% assign message = 'تمت العملية بنجاح.' %} |
| 396 | +{% assign title = 'تهانينا' %} |
399 | 397 | {% assign options = '{"rtl": true}' %}
|
400 | 398 | {% include example.html %}
|
401 | 399 |
|
402 | 400 | ```php
|
403 | 401 | {{ id }}
|
404 | 402 |
|
405 |
| -flash()->add{{ type | capitalize }}('{{ message }}'); |
| 403 | +flash() |
| 404 | + ->translate('ar') |
| 405 | + ->add{{ type | capitalize }}('Your request was processed successfully.', 'Congratulations!'); |
406 | 406 | ```
|
407 | 407 |
|
408 | 408 | ---
|
409 | 409 |
|
410 | 410 | ## <i class="fa-duotone fa-list-radio"></i> Translation
|
411 | 411 |
|
412 |
| -**<span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span>** allows you to translate your notification messages, presets and automatically detect right-to-left (RTL) support. |
413 |
| - |
414 |
| -**<span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span>** comes with Arabic, English and French translations out of the box, but you can easily add your own translations. |
| 412 | +**<span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span>** allows you to translate your notification `messages`, `presets`, it comes with `Arabic`, `English` and `French` translations out of the box, but you can easily add your own translations. |
415 | 413 |
|
416 | 414 | For example, if you need to override the English translation strings for **<span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span>**, you can create a language file at the following location:
|
417 | 415 | **`/resources/lang/vendor/flasher/en/messages.php`**.
|
418 | 416 |
|
419 |
| -In this file, you should only define the translation strings you want to override. Any translation strings that you don't override will still be loaded from **<span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span>**'s original language files. |
| 417 | +In this file, you should **only** define the translation strings you want to override. Any translation strings that you don't override will still be loaded from **<span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span>**'s original language files. |
420 | 418 |
|
421 | 419 | Here is a list of the default translation keys for **<span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span>**:
|
422 | 420 |
|
@@ -475,7 +473,7 @@ return [
|
475 | 473 | ```
|
476 | 474 |
|
477 | 475 | {% assign id = '# laravel arabic translations' %}
|
478 |
| -{% assign successMessage = 'تم إرسال طلبك بنجاح.' %} |
| 476 | +{% assign successMessage = 'تم إنشاء الملف' %} |
479 | 477 | {% assign errorMessage = 'حدث خطأ أثناء إرسال طلبك.' %}
|
480 | 478 | {% assign warningMessage = 'يجب إكمال جميع الحقول الإلزامية قبل إرسال النموذج' %}
|
481 | 479 | {% assign infoMessage = 'سيتم تحديث هذه الصفحة في غضون 10 دقائق.' %}
|
@@ -517,14 +515,21 @@ return [
|
517 | 515 | ```php
|
518 | 516 | {{ id }}
|
519 | 517 |
|
520 |
| -flash()->addSuccess('{{ successMessage }}'); |
| 518 | +use Illuminate\Support\Facades\App; |
| 519 | + |
| 520 | +// Set the locale to be used for the translation |
| 521 | +App::setLocale('ar'); |
| 522 | + |
| 523 | +// Translate the flash message using the PHPFlasher translation files |
| 524 | +flash()->addSuccess('The resource was created'); |
| 525 | + |
521 | 526 | flash()->addError('{{ errorMessage }}');
|
522 | 527 | flash()->addWarning('{{ warningMessage }}');
|
523 | 528 | flash()->addInfo('{{ infoMessage }}');
|
524 | 529 | ```
|
525 | 530 |
|
526 | 531 | {% assign id = '# laravel french translations' %}
|
527 |
| -{% assign successMessage = "Votre demande a été envoyée avec succès." %} |
| 532 | +{% assign successMessage = "La ressource a été ajoutée" %} |
528 | 533 | {% assign errorMessage = "Une erreur s’est produite lors de l’envoi de votre demande." %}
|
529 | 534 | {% assign warningMessage = "Vous devez remplir tous les champs obligatoires avant de soumettre le formulaire." %}
|
530 | 535 | {% assign infoMessage = "Cette page sera mise à jour dans 10 minutes."%}
|
@@ -566,116 +571,19 @@ flash()->addInfo('{{ infoMessage }}');
|
566 | 571 | ```php
|
567 | 572 | {{ id }}
|
568 | 573 |
|
569 |
| -flash()->addSuccess('{{ successMessage }}'); |
570 |
| -flash()->addError('{{ errorMessage }}'); |
571 |
| -flash()->addWarning('{{ warningMessage }}'); |
572 |
| -flash()->addInfo('{{ infoMessage }}'); |
573 |
| -``` |
574 |
| - |
575 |
| ---- |
576 |
| - |
577 |
| -## <i class="fa-duotone fa-list-radio"></i> cdn - local - npm |
578 |
| - |
579 |
| -By default **<span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span>** use **cdn** link to include all of its assets. |
580 |
| - |
581 |
| -To pull in the **<span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span>** via CDN, grab the latest version from [jsdelivr](https://www.jsdelivr.com/package/npm/@flasher/flasher) |
582 |
| - |
583 |
| -<span> |
584 |
| - <a href="https://cdn.jsdelivr.net/npm/@flasher/flasher/dist/flasher.min.js" target="_blank"> |
585 |
| - <img src="https://img.shields.io/badge/cdn-jsdelivr-blue.svg?style=flat-square" alt="cdn-jsdelivr" /> |
586 |
| - </a> |
587 |
| - <a href="https://cdn.jsdelivr.net/npm/@flasher/flasher/dist/flasher.min.js"> |
588 |
| - <img src="https://img.badgesize.io/php-flasher/flasher-js/main/packages/flasher/dist/flasher.min.js.svg?compression=brotli&label=flasher.min.js"/> |
589 |
| - </a> |
590 |
| -</span> |
591 |
| - |
592 |
| -```html |
593 |
| -<script defer src="https://cdn.jsdelivr.net/npm/@flasher/flasher@1.2.4/dist/flasher.min.js"></script> |
594 |
| -``` |
595 |
| - |
596 |
| -<br/> |
597 |
| - |
598 |
| -But you can use **local** version of the assets or install them using **npm**. |
599 |
| - |
600 |
| ---- |
601 |
| - |
602 |
| -To use the **local** version of the assets, first publish the assets to the public folder by running: |
603 |
| - |
604 |
| -```shell |
605 |
| -php artisan vendor:publish --force --tag=flasher-assets |
606 |
| -``` |
607 |
| - |
608 |
| -The published assets will be copied to the `/public/vendor/flasher` folder. |
609 |
| - |
610 |
| -Then update the configuration file at `config/flasher.php`, set **`use_cdn`** to false |
611 |
| - |
612 |
| -```php |
613 |
| -<?php // config/flasher.php |
614 |
| - |
615 |
| -return [ |
616 |
| - /* |
617 |
| - |-------------------------------------------------------------------------- |
618 |
| - | Whether to use CDN for PHPFlasher assets or not |
619 |
| - |-------------------------------------------------------------------------- |
620 |
| - | This option controls whether PHPFlasher should use CDN links or local assets |
621 |
| - | for its javascript and CSS files. By default, PHPFlasher uses CDN links |
622 |
| - | to serve the latest version of the library. However, you can also choose |
623 |
| - | to use local assets by setting this option to 'false'. |
624 |
| - | |
625 |
| - | If you decide to use local assets, don't forget to publish the necessary |
626 |
| - | files to your application's public folder by running the following command: |
627 |
| - | php artisan vendor:publish --force --tag=flasher-assets |
628 |
| - | |
629 |
| - | This will copy the necessary assets to your application's public folder. |
630 |
| - */ |
631 |
| - 'use_cdn' => true, |
632 |
| -]; |
633 |
| -``` |
634 |
| - |
635 |
| ---- |
| 574 | +use Illuminate\Support\Facades\App; |
636 | 575 |
|
637 |
| -To install **<span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span>** using npm, run the following command: |
| 576 | +// Set the locale to be used for the translation |
| 577 | +App::setLocale('fr'); |
638 | 578 |
|
639 |
| -```shell |
640 |
| -npm i @flasher/flasher |
641 |
| -``` |
642 |
| - |
643 |
| -<br/> |
| 579 | +// Translate the flash message using the PHPFlasher translation files |
| 580 | +flash()->addSuccess('The resource was created'); |
644 | 581 |
|
645 |
| -Then attach `flasher` to the `window` object. Add the following lines at the end of your application's `/resources/js/bootstrap.js` file: |
646 |
| - |
647 |
| -```javascript |
648 |
| -import flasher from "@flasher/flasher"; |
649 |
| -window.flasher = flasher; |
| 582 | +flash()->addError('{{ errorMessage }}'); |
| 583 | +flash()->addWarning('{{ warningMessage }}'); |
| 584 | +flash()->addInfo('{{ infoMessage }}'); |
650 | 585 | ```
|
651 | 586 |
|
652 |
| -Then update the configuration file: |
653 |
| - |
654 |
| -```php |
655 |
| -<?php // /config/flasher.php |
656 |
| - |
657 |
| -return [ |
658 |
| - /* |
659 |
| - |-------------------------------------------------------------------------- |
660 |
| - | Main PHPFlasher javascript file |
661 |
| - |-------------------------------------------------------------------------- |
662 |
| - | This option specifies the location of the main javascript file that is |
663 |
| - | required by PHPFlasher to display notifications in your Laravel application. |
664 |
| - | |
665 |
| - | By default, PHPFlasher uses a CDN to serve the latest version of the library. |
666 |
| - | However, you can also choose to download the library locally or install it |
667 |
| - | using npm. |
668 |
| - | |
669 |
| - | To use the local version of the library, run the following command: |
670 |
| - | php artisan vendor:publish --force --tag=flasher-assets |
671 |
| - | |
672 |
| - | This will copy the necessary assets to your application's public folder. |
673 |
| - | You can then specify the local path to the javascript file in the 'local' |
674 |
| - | field of this option. |
675 |
| - */ |
676 |
| - 'root_script' => [], // set this to empty array |
677 |
| -]; |
678 |
| -``` |
679 | 587 | ---
|
680 | 588 |
|
681 | 589 | ## <i class="fa-duotone fa-list-radio"></i> Laravel version < 5.5
|
|
0 commit comments