Reputation: 3274
I know that in Wordpress we can do the following:
preg_match("/\p{Arabic}/u",
get_the_title())
How can we do this in JavaScript? Thanks in advance.
Upvotes: 0
Views: 1236
Reputation: 1170
Since you know how to detect your language in php then its just a simple matter of passing a value from your php code to your javascript code.
eg.
<?php $language = get_language_on_whatever_way_you_want(); ?>
<script type="text/javascript">
function alertMeTheLanguage() {
var language = '<?php echo $language; ?>';
alert('Your language is <?php echo $language; ?> ' );
}
</script>
Upvotes: 0
Reputation: 41080
You could do this via the Google Language API Detect language from string in PHP
Upvotes: 2