Hi. I am wanting to create an equivalent array of translation phrases for use my custom javascript functions. Is there any way (in razor if possible) I can loop through the Dictionary, getting each alias and translation so I can generate an javascript object. I can find much documentation about using the localizationservice and dictionary. I'm using the latest version 7 of Umbraco.
Hi mike i believe all languages are currently held in xml files in umbraco so maybe as a last resort you could load the relevant language into javascript.
But really the localization service is there to just get the strings you need. If you are in, the backed you can just use the angular localize directive which keeps everything more javascript oriented. Even if you can't use the directive for your needs you could take a look at its code to get a head start on creating something yourself
Hi. Thanks for the reply! I'm looking at using translations in the front-end of a multi-language website. Rather than duplicate all the language 'if-this-then-write-that' code I wanted to use the values already entered in the back-end. I'll take a look at the code and see if I can work it out. Thanks again!
Passing all dictionary translations to javascript
Hi. I am wanting to create an equivalent array of translation phrases for use my custom javascript functions. Is there any way (in razor if possible) I can loop through the Dictionary, getting each alias and translation so I can generate an javascript object. I can find much documentation about using the localizationservice and dictionary. I'm using the latest version 7 of Umbraco.
Thanks!
Hi mike i believe all languages are currently held in xml files in umbraco so maybe as a last resort you could load the relevant language into javascript.
But really the localization service is there to just get the strings you need. If you are in, the backed you can just use the angular localize directive which keeps everything more javascript oriented. Even if you can't use the directive for your needs you could take a look at its code to get a head start on creating something yourself
Hi. Thanks for the reply! I'm looking at using translations in the front-end of a multi-language website. Rather than duplicate all the language 'if-this-then-write-that' code I wanted to use the values already entered in the back-end. I'll take a look at the code and see if I can work it out. Thanks again!
Hi Mike,
You could try to have a look at the Dictionary 2 JavaScript package and maybe see how it's done. The source is available as far as I can see...
Hope that helps,
/Chriztian
Thanks Chriztian. I'll take a look. In the meantime I've got this far...
I'll do a few tests and see how I get on with this :)
Cheers!
Seems to work! :)
is working on a reply...