'How can i use Laraval Lang with JS confirm model?
<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 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | DharmanBot |