Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Document how to use with AssetMapper #355

Open
tacman opened this issue May 2, 2024 · 1 comment
Open

Document how to use with AssetMapper #355

tacman opened this issue May 2, 2024 · 1 comment

Comments

@tacman
Copy link
Contributor

tacman commented May 2, 2024

I'd like to use this bundle with AssetMapper, and install the translations during the compile that than from a script tag.

Like the jsRoutingBundle, this is a bit a tricky, since you can't simply load JSON:

FriendsOfSymfony/FOSJsRoutingBundle#466

It certainly looks possible, to dump the message as js rather than json and then load it, but I was wondering if anyone had already done this and could point to how to do it.

Thanks!

@alainsharemat
Copy link

I was looking for a solution for the same problem. I ended up importing translations like that

// This will load the translation for the 'admin' domain (this is what path('bazinga_jstranslation_js', { 'domain': 'admin' }) would return in twig, adjust with your own path)
import '/path/to/translations/admin'

// Then load the Translator object 
import Translator from 'bazinga-translator'

console.log(Translator.trans('whatever'))

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants