PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, April 19, 2022

[FIXED] How can i use Laraval Lang with JS confirm model?

 April 19, 2022     javascript, jquery, laravel, laravel-8     No comments   

Issue

<script type="text/javascript">
$('.ask').on('click', function () {
var message = "{{ __('so.fields.are-you-sure') }}";
     confirm(message);
}
</script>

I want to show Yes, No text which is in Lang file on confirm button. How can I do this? Which code do I need to add?

Or is this possible with jQuery?


Solution

Your code works, just make sure that the translation exists according to the attached snippet it should be found in en/so/fields.php file - en is the language dir as example

and contains the index

return [
    'are-you-sure' => 'Are you Sure!',
];

But, if you are asking about localizing the confirm buttons this method depends on the language of web browser, not your preferred language

instead of using confirm you can use jQuery UI Dialog's modal confirmation

so you can translate the buttons & customize the dialog as you like.



Answered By - Omar Tammam
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing