Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a CSV file which contains list of words and translated words in different language.
I looked into Services.LocalizationService service, and found a method call Save();
But i can't seems to get it to work, do you guys have any example i can use? or any other way of storing translation dictionary?
There is some documentation on the Localization service here:
In terms of an example, I use it in my DictionaryItemKeySearch dashboard, to save an updated dictionary item translation:
but also If you are creating dictionary items from scratch for an import then the following should work as an example:
var ls = ApplicationContext.Current.Services.LocalizationService;
//create a holder for the item's DictionaryTranslations
List<DictionaryTranslation> _translations = new List<DictionaryTranslation>();
//the constructor for a DictionaryItem requires the Umbraco language object and value of the translated text
//so get the language object, eg from Iso Code
var language = ls.GetLanguageByIsoCode("fr-FR");
// here we create a french translation for our item and add it to the list
DictionaryTranslation dt = new DictionaryTranslation(language, "bonjour le monde");
//get or create a DictionaryItem, (passing in the Dictionary Key)
IDictionaryItem di = ls.DictionaryItemExists("HelloWorld") ? ls.GetDictionaryItemByKey("HelloWorld") : new DictionaryItem("HelloWorld");
// set the translations created above
di.Translations = _translations;
//now save the dictionary item and translations to Umbraco
Hello Marc,Thanks for this post! I found this incredibly helpful.BR / Steve
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted