public Item AddTranslation( string dictionaryPath, TemplateItem dictionaryEntryTemplate, string key, bool alphabeticalRegister = true, bool addToAllDictionaries = false) { var fields = TemplateFieldsProvider.TranslationTemplateFields(key); var item = ItemUtil.CreateItemPath( Database, PathUtil.Combine( dictionaryPath.CreateRegisterItemPath( Database, key, AlphabeticRegister, DictionaryFolderTemplate), key), dictionaryEntryTemplate, fields).CreateLanguageVersions(Database); if (addToAllDictionaries) { CreateTranslationForAllDictionaries(key, dictionaryEntryTemplate, fields); } return(item); }
private void CreateTranslationForAllDictionaries( string key, TemplateItem dictionaryEntryTemplate, Dictionary <string, string> fields) { var dictionaries = SiteUtil.GetConfiguredDictionariesFromOtherSites(); foreach ( var dictionaryPath in dictionaries.Select(DictionaryPath) .Where(dictionaryPath => dictionaryPath != Dictionary.GetDefinitionItem().Paths.Path)) { var item = Database.GetItem( PathUtil.Combine( dictionaryPath.CreateRegisterItemPath( Database, key, AlphabeticRegister, DictionaryFolderTemplate), key)); if (item == null) { ItemUtil.CreateItemPath( Database, PathUtil.Combine( dictionaryPath.CreateRegisterItemPath( Database, key, AlphabeticRegister, DictionaryFolderTemplate), key), dictionaryEntryTemplate, fields).CreateLanguageVersions(Database); } } }