Exemple #1
0
        /// <summary>
        /// Adds a translation for the TOM object based on the supplied AMOTranslation.
        /// Creates the relevant culture if it does not exist.
        /// </summary>
        /// <param name="TOMDatabase">The TOM Database to add the Translation to</param>
        /// <param name="TOMObject">The TOM Object the translation is being added for</param>
        /// <param name="AMOTranslation">The AMO Translation being transferred to the TOM Database</param>
        public static void AddTOMTranslation(TOM.Database TOMDatabase, TOM.MetadataObject TOMObject, AMO.Translation AMOTranslation)
        {
            string CultureName = TranslationHelper.GetCultureNameFromLCID(AMOTranslation.Language);

            //Add Culture if it does not exist
            if (!TOMDatabase.Model.Cultures.ContainsName(CultureName))
            {
                TOMDatabase.Model.Cultures.Add(new TOM.Culture {
                    Name = CultureName
                });
            }

            //Get existing culture
            TOM.Culture TOMCulture = TOMDatabase.Model.Cultures.Find(CultureName);

            //Add the various translated properties to the translation
            TOMCulture.ObjectTranslations.Add(
                new TOM.ObjectTranslation {
                Object = TOMObject, Property = TOM.TranslatedProperty.Caption, Value = AMOTranslation.Caption
            }
                );
            TOMCulture.ObjectTranslations.Add(
                new TOM.ObjectTranslation {
                Object = TOMObject, Property = TOM.TranslatedProperty.Description, Value = AMOTranslation.Description
            }
                );
            TOMCulture.ObjectTranslations.Add(
                new TOM.ObjectTranslation {
                Object = TOMObject, Property = TOM.TranslatedProperty.DisplayFolder, Value = AMOTranslation.DisplayFolder
            }
                );
        }
Exemple #2
0
        public static AMO.Translation GetTranslation(TOM.Culture TOMCulture, TOM.MetadataObject TOMObject)
        {
            AMO.Translation AMOTranslation = new AMO.Translation
            {
                Language = GetLCIDFromCultureName(TOMCulture.Name)
            };

            //Caption (i.e. Name)
            if (TOMCulture.ObjectTranslations[TOMObject, TOM.TranslatedProperty.Caption] != null)
            {
                AMOTranslation.Caption = TOMCulture.ObjectTranslations[TOMObject, TOM.TranslatedProperty.Caption].Value;
            }

            //Description
            if (TOMCulture.ObjectTranslations[TOMObject, TOM.TranslatedProperty.Description] != null)
            {
                AMOTranslation.Description = TOMCulture.ObjectTranslations[TOMObject, TOM.TranslatedProperty.Description].Value;
            }

            //Display Folder
            if (TOMCulture.ObjectTranslations[TOMObject, TOM.TranslatedProperty.DisplayFolder] != null)
            {
                AMOTranslation.DisplayFolder = TOMCulture.ObjectTranslations[TOMObject, TOM.TranslatedProperty.DisplayFolder].Value;
            }

            // If translation has no properties, it does not exist.
            // As such, return null unless it has at least one valid property
            if (AMOTranslation.Caption != null || AMOTranslation.Description != null || AMOTranslation.DisplayFolder != null)
            {
                return(AMOTranslation);
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the Culture class using multiple parameters.
 /// </summary>
 /// <param name="parentTabularModel">TabularModel object that the Culture object belongs to.</param>
 /// <param name="tomCulture">Tabular Object Model Culture object abtstracted by the Culture class.</param>
 public Culture(TabularModel parentTabularModel, Tom.Culture tomCulture) : base(tomCulture, parentTabularModel)
 {
     _parentTabularModel = parentTabularModel;
     _tomCulture         = tomCulture;
 }