I have a string that I need to wrapped using Yii tag like Yii::t('app' , 'what_string') because I need this to translate per string in other page. But here, there is a word that place on alphineJs and I cant to wrap it using PHP Yii::t('app' , .. anyone can help me how to wrap something like this?
My code in alphine:
get articleCount() {
if (this.blog.articles.length === this.blogArticle.length) return `${this.blog.articles.length <?=Yii::t('app', 'Article(s)')?> `
return `${this.course.topics.length} Article(s), ${this.blogArticle.length} Filtered`
},
Here, I want to wrap 'Article(s)' so I just added but it doesn't work here
You are mixing client-side (JavaScript/Alpine) and server-side code (PHP/Yii). While this is possible to some extend when sending JS code back from the server via PHP, the same cannot be said about the opposite direction, thus, rendering PHP code inside JS is not possible. You need to send your i18n messages to the client one way or the other.
Solution A
Solution B
Solution C