/// <summary> /// Constructs the language phrase translation with details /// </summary> /// <param name="phrase">The phrase</param> /// <param name="languageId">The language ID</param> /// <param name="translatedText">The translated phrase text</param> internal RegisteredPhraseTranslation ( RegisteredPhrase phrase, Guid languageId, string translatedText ) { Validate.IsNotNull(phrase); this.TranslationId = Guid.NewGuid(); this.Phrase = phrase; this.LanguageId = languageId; this.TranslatedText = translatedText; }
/// <summary> /// Creates a phrase /// </summary> /// <param name="configuration">The phrase configuration</param> /// <returns>The phrase created</returns> public RegisteredPhrase CreatePhrase ( RegisteredPhraseConfiguration configuration ) { EnsurePhraseAvailable(configuration); var phrase = new RegisteredPhrase ( configuration ); _phraseRepository.AddPhrase(phrase); _unitOfWork.SaveChanges(); RegisteredPhraseTranslatorFactory.ClearCache(); return(phrase); }
/// <summary> /// Auto registers the phrases specified /// </summary> /// <param name="configurations">The phrase configurations</param> public void AutoRegisterPhrases ( params RegisteredPhraseConfiguration[] configurations ) { Validate.IsNotNull(configurations); var changesMade = false; foreach (var configuration in configurations) { var registered = _phraseRepository.HasBeenRegistered ( configuration.PhraseText ); if (false == registered) { var phrase = new RegisteredPhrase ( configuration ); _phraseRepository.AddPhrase ( phrase ); changesMade = true; } } if (changesMade) { _unitOfWork.SaveChanges(); } }