Frage

I'm asking if it's possible to use translations in Symfony2 as, for example, sprint_f() PHP functions does. By using sprint_f() is so easy as:

$message = 'Are you sure to delete the %element%?';
echo sprintf($message , "element_name");

And the output will be: "Are you sure to delete the element_name?", that's easy. Now I have the translation file in YML format and I wrote this:

delete.message: Are you sure to delete the %element%?

But this will work? I check docs here and here but since I'm using BazingaJSTranslationBundle I don't know how to get this working on this scenario. Any help or advice?

War es hilfreich?

Lösung

Add this to your messages.en.yml:

delete.message: Are you sure to delete the %element%?

Now call it in js:

Translator.trans('delete.message', { "element" : "YOUR VALUE" }, 'messages');

Explanation found in the BazingaJsTranslationBundle docs.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top