-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Webpack encore #276
Comments
Feel free to submit a PR, it is an open source project all contributions are welcome |
I would like but, I didn't achieve to make it working. At least some help and I will submit a PR if needed. |
you can try my sugestion #254 (comment) |
Thanks @drjele for your proposition, I'll try but the solution seem weird |
I've also implemented something inspired by @drjele:
Which I require via webpack where I need translations:
When deploying or updating: |
@willdurand and @kl3sk i have found a problem with my solution .. the async translation load might not happen fast enough and a pice of code might use the translator and still display the translation key and not the translation. |
Hello, I've just tested @wumke solution and made it work! I'm just wondering if I should also include generated config.js file. As far as I can see, Translator.trans is still working but I'd appreciate any suggestion about my question. |
Below is another solution that I find more practical:
...
<html lang="{{ app.request.locale|split('_')[0] }}">
...
{% block javascripts %}
{% set transScript = render(controller('bazinga.jstranslation.controller::getTranslationsAction',{"domain":"messages","_format":"js"}))|split('\n') %}
<script type="text/javascript">
var translationscript= ''; //this variable is in global scope
{% for transScriptLine in transScript %}
{% if transScriptLine|raw|trim|slice(0,2) != '//' %}
translationscript+= '{{ transScriptLine|replace({"'":"\\'","\\n":""})|raw }}';
{% endif %}
{% endfor %}
</script>
{{ encore_entry_script_tags('app') }}
{% endblock %}
import Translator from 'bazinga-translator';
global.Translator = Translator; // this is needed to eval the script
eval(translationscript); //translationscript comes from global scope.
console.log(Translator.trans('your.translation.key',{},'messages')); //it works !!! |
I know there is a lot of topic about this, but there is a lot of informations and not working for me.
The doc are not updated with
Encore
, so does maintainers could provide an "official" way to enable it ?The text was updated successfully, but these errors were encountered: