/// <summary> /// Gets a phrase translation dictionary instance /// </summary> /// <returns>The phrase translation dictionary</returns> public PhraseTranslationDictionary GetDictionary() { if (RegisteredPhraseTranslatorFactory.CachedDictionary != null) { return(RegisteredPhraseTranslatorFactory.CachedDictionary); } else { var translator = new PhraseTranslationDictionary(); var languages = _languageRepository.GetAllLanguages().ToList(); var phrases = _phraseRepository.GetAllPhrases().ToList(); foreach (var phrase in phrases) { var translations = new Dictionary <Language, string>(); foreach (var translation in phrase.Translations.ToList()) { var language = ToLanguage ( translation.LanguageId ); translations.Add ( language, translation.TranslatedText ); } translator.Add ( phrase.PhraseText, translations ); } Language ToLanguage(Guid languageId) { var registeredLanguage = languages.FirstOrDefault ( l => l.Id == languageId ); if (registeredLanguage == null) { throw new KeyNotFoundException ( "The registered language was not found." ); } return(registeredLanguage.ToLanguage()); } RegisteredPhraseTranslatorFactory.CachedDictionary = translator; return(translator); } }
/// <summary> /// Translates the report section to the language specified /// </summary> /// <param name="translator">The translation dictionary</param> /// <param name="language">The language to translate into</param> public void Translate ( PhraseTranslationDictionary translator, Language language ) { Validate.IsNotNull(translator); Validate.IsNotNull(language); this.Title = translator.Translate ( this.Title, language ); this.Description = translator.Translate ( this.Description, language ); foreach (var component in this.Components) { component.Translate ( translator, language ); } }
/// <summary> /// Translates the report to the language specified /// </summary> /// <param name="translator">The translation dictionary</param> /// <param name="language">The language to translate into</param> public void Translate ( PhraseTranslationDictionary translator, Language language ) { Validate.IsNotNull(translator); Validate.IsNotNull(language); this.Title = translator.Translate ( this.Title, language ); this.Description = translator.Translate ( this.Description, language ); foreach (var section in this.AllSections) { if (section != null) { section.Translate ( translator, language ); } } }
/// <summary> /// Translates the report category to the language specified /// </summary> /// <param name="translator">The translation dictionary</param> /// <param name="language">The language to translate into</param> public void Translate ( PhraseTranslationDictionary translator, Language language ) { Validate.IsNotNull(translator); Validate.IsNotNull(language); this.Title = translator.Translate ( this.Title, language ); this.Description = translator.Translate ( this.Description, language ); foreach (var subCategory in this.SubCategories.ToList()) { subCategory.Translate ( translator, language ); } }
/// <summary> /// Translates the text in the component to the language specified /// </summary> /// <param name="translator">The translation dictionary</param> /// <param name="language">The language to translate into</param> public virtual void Translate ( PhraseTranslationDictionary translator, Language language ) { Validate.IsNotNull(translator); Validate.IsNotNull(language); // NOTE: nothing to do for the base component }
/// <summary> /// Translates the text in the component to the language specified /// </summary> /// <param name="translator">The translation dictionary</param> /// <param name="language">The language to translate into</param> public override void Translate ( PhraseTranslationDictionary translator, Language language ) { base.Translate(translator, language); this.Title = translator.Translate ( this.Title, language ); }
/// <summary> /// Constructs the report categorizer with required dependencies /// </summary> /// <param name="categoryRepository">The category repository</param> /// <param name="translatorFactory">The translator factory</param> /// <param name="unitOfWork">The unit of work</param> public ReportCategorizer ( IReportCategoryRepository categoryRepository, IPhraseTranslatorFactory translatorFactory, IUnitOfWork unitOfWork ) { Validate.IsNotNull(categoryRepository); Validate.IsNotNull(translatorFactory); Validate.IsNotNull(unitOfWork); _categoryRepository = categoryRepository; _translator = translatorFactory.GetDictionary(); _unitOfWork = unitOfWork; }
/// <summary> /// Constructs the report generator with required dependencies /// </summary> /// <param name="filterGenerator">The filter generator</param> /// <param name="translatorFactory">The phrase translation factory</param> public ReportGenerator ( IReportFilterGenerator filterGenerator, IPhraseTranslatorFactory translatorFactory = null ) { Validate.IsNotNull(filterGenerator); if (translatorFactory == null) { translatorFactory = new EmptyPhraseTranslatorFactory(); } _filterGenerator = filterGenerator; _translator = translatorFactory.GetDictionary(); }
/// <summary> /// Translates the text in the component to the language specified /// </summary> /// <param name="translator">The translation dictionary</param> /// <param name="language">The language to translate into</param> public override void Translate ( PhraseTranslationDictionary translator, Language language ) { base.Translate(translator, language); foreach (var column in this.Columns) { TranslateColumn(column); } foreach (var row in this.AllRows) { foreach (var cell in row) { TranslateColumn(cell.Column); } } if (this.HasTotals) { foreach (var cell in this.Totals) { TranslateColumn(cell.Column); } } void TranslateColumn(TableColumn column) { column.Name = translator.Translate ( column.Name, language ); column.Title = translator.Translate ( column.Title, language ); } }
/// <summary> /// Translates the text in the component to the language specified /// </summary> /// <param name="translator">The translation dictionary</param> /// <param name="language">The language to translate into</param> public override void Translate ( PhraseTranslationDictionary translator, Language language ) { base.Translate(translator, language); foreach (var item in this.Items) { foreach (var component in item.NestedComponents) { component.Translate ( translator, language ); } } }
/// <summary> /// Constructs the report categorizer with required dependencies /// </summary> /// <param name="reportRepository">The report repository</param> /// <param name="categoryRepository">The category repository</param> /// <param name="roleAssignmentRepository">The role assignment repository</param> /// <param name="translatorFactory">The translator factory</param> /// <param name="unitOfWork">The unit of work</param> public ReportRegistrar ( IRegisteredReportRepository reportRepository, IReportCategoryRepository categoryRepository, IReportRoleAssignmentRepository roleAssignmentRepository, IPhraseTranslatorFactory translatorFactory, IUnitOfWork unitOfWork ) { Validate.IsNotNull(reportRepository); Validate.IsNotNull(categoryRepository); Validate.IsNotNull(roleAssignmentRepository); Validate.IsNotNull(translatorFactory); Validate.IsNotNull(unitOfWork); _reportRepository = reportRepository; _categoryRepository = categoryRepository; _roleAssignmentRepository = roleAssignmentRepository; _translator = translatorFactory.GetDictionary(); _unitOfWork = unitOfWork; }
/// <summary> /// Translates the registered report to the language specified /// </summary> /// <param name="translator">The translation dictionary</param> /// <param name="language">The language to translate into</param> public void Translate ( PhraseTranslationDictionary translator, Language language ) { Validate.IsNotNull(translator); Validate.IsNotNull(language); this.Title = translator.Translate ( this.Title, language ); this.Description = translator.Translate ( this.Description, language ); }
/// <summary> /// Translates the text in the component to the language specified /// </summary> /// <param name="translator">The translation dictionary</param> /// <param name="language">The language to translate into</param> public override void Translate ( PhraseTranslationDictionary translator, Language language ) { base.Translate(translator, language); foreach (var label in this.XAxisLabels) { label.CustomText = translator.Translate ( label.CustomText, language ); label.ToolTip = translator.Translate ( label.ToolTip, language ); } }
/// <summary> /// Translates the text in the component to the language specified /// </summary> /// <param name="translator">The translation dictionary</param> /// <param name="language">The language to translate into</param> public override void Translate ( PhraseTranslationDictionary translator, Language language ) { base.Translate(translator, language); foreach (var overlay in this.Overlays) { if (overlay.HasLabel) { overlay.Label = translator.Translate ( overlay.Label, language ); } } foreach (var statistic in this.OverlayStatistics) { statistic.Value.ForEach ( s => s.Translate(translator, language) ); } foreach (var area in this.Areas) { area.ToolTipText = translator.Translate ( area.ToolTipText, language ); } }
/// <summary> /// Clears the factory cache /// </summary> internal static void ClearCache() { RegisteredPhraseTranslatorFactory.CachedDictionary = null; }