示例#1
0
        public ImageItem(
            string productImageID,
            string thumbnailImage,
            string regularImage,
            string largeImage,
            int imageSize,
            int sortOrder,
            bool isZoom,
            bool isEnlarge,
            int imageWidth,
            int imageHeight,
            Culture culture,
            string altTag,
            string titleTag
            )
        {
            _productImageID = productImageID;
            _thumbnailImage = thumbnailImage;
            _regularImage   = regularImage;
            _largeImage     = largeImage;
            _imagize        = imageSize;
            _sortOrder      = sortOrder;
            _isZoom         = isZoom;
            _isEnlarge      = isEnlarge;
            _imageWidth     = imageWidth;
            _imageHeight    = imageHeight;

            _locales = new LocaleCollection <ProductImageLocale>(this);
            Locales[culture].AltTag   = altTag;
            Locales[culture].TitleTag = titleTag;
        }
示例#2
0
 public LocalizationService(
     IUnitOfWork context,
     LocaleCollection locales,
     Config config = null)
 {
     this.context    = context;
     this.locales    = locales;
     this.repository = context.GetRepository <ChannelLanguage>();
     this.config     = config ?? new Config();
 }
示例#3
0
        private ILocalizationService CreateService(IUnitOfWork context)
        {
            var collection = new LocaleCollection();

            collection.Add(new Locale("eng", null));
            collection.Add(new Locale("dut", null));

            var service = new LocalizationService(context, collection);

            return(service);
        }
        public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(DotNetNuke.Entities.Modules.ModuleInfo ModInfo)
        {
            SearchItemInfoCollection SearchItemCollection = new SearchItemInfoCollection();
            LocaleCollection         lCollection          = Localization.GetEnabledLocales();

            foreach (Locale localeInfo in lCollection)
            {
                effority.Ealo.StringInfo objText;
                effority.Ealo.StringInfo objSummary;
                objText    = effority.Ealo.Controller.GetStringByQualifierAndStringName(Consts.DesktopHTMLQualifier, ModInfo.ModuleID.ToString(), localeInfo.Code, true);
                objSummary = effority.Ealo.Controller.GetStringByQualifierAndStringName(Consts.DesktopSummaryQualifier, ModInfo.ModuleID.ToString(), localeInfo.Code, true);
                if (!objText.StringTextIsNull)
                {
                    string         strDesktopHtml = HttpUtility.HtmlDecode(objText.StringText);
                    string         strDescription = HtmlUtils.Shorten(HtmlUtils.Clean(strDesktopHtml, false), MAX_DESCRIPTION_LENGTH, "...");
                    SearchItemInfo SearchItem     = new SearchItemInfo(ModInfo.ModuleTitle, localeInfo.Text + " - " + strDescription, -1, DateTime.Now, ModInfo.ModuleID, "", objSummary.StringText + " " + strDesktopHtml, "", Null.NullInteger);
                    SearchItemCollection.Add(SearchItem);
                }
            }
            return(SearchItemCollection);
        }
示例#5
0
 public void ParseTemplate(int portalId, string templatePath, string templateFile, int administratorId, PortalTemplateModuleAction mergeTabs, bool isNewPortal, out LocaleCollection localeCollection)
 {
     ParseTemplateInternal(portalId, templatePath, templateFile, administratorId, mergeTabs, isNewPortal, out localeCollection);
 }
示例#6
0
        private void OnLoad(object sender, EventArgs e)
        {
            // The list of locales.
            HashSet<string> locales = new HashSet<string>();
            foreach (string locale in this.textBoxLocales.Text.Split(new char[] { ' ', ',', ';', '/' }, StringSplitOptions.RemoveEmptyEntries))
            {
                locales.Add(locale);
            }

            // If the list of locales is empty, do nothing.
            if (locales.Count == 0)
            {
                this.textBoxOutput.AppendText("Matching all locales.");
            }

            // Disable the controls.
            this.buttonLoad.Enabled = false;
            this.textBoxLocales.Enabled = false;

            // Set the dialog properties.
            this.openFileDialog.Filter = "CLDR ZIP files (*.zip)|*.zip";
            this.openFileDialog.Title = "Open CLDR Zip File";

            // Load the CLDR file.
            if (this.openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                // Get the file name.
                string fileName = this.openFileDialog.FileName;

                ThreadPool.QueueUserWorkItem((object state) =>
                    {
                        try
                        {
                            // Open the CLDR file.
                            using (FileStream fileZip = new FileStream(fileName, FileMode.Open))
                            {
                                // Open the ZIP archive.
                                using (ZipArchive zip = new ZipArchive(fileZip, ZipArchiveMode.Read))
                                {
                                    // Create a locale collection.
                                    LocaleCollection localeCollection = new LocaleCollection();

                                    // Parse all entries.
                                    foreach (ZipArchiveEntry zipEntry in zip.Entries)
                                    {
                                        // If the file name does not match the common path, skip too next file.
                                        if (!Regex.IsMatch(zipEntry.FullName, @"^common/main/.+?\.xml$")) continue;
                                        if (!Regex.IsMatch(zipEntry.Name, @"^.+?\.xml$")) continue;

                                        // If there is a list of locales.
                                        if (locales.Count > 0)
                                        {
                                            // Get the locale name.
                                            string localeName = zipEntry.Name.Substring(0, zipEntry.Name.Length - 4);

                                            // If the locale name does not exist, continue.
                                            if (!locales.Contains(localeName)) continue;
                                        }

                                        // Get a temporary file name.
                                        string tempFileName = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

                                        this.Invoke(() =>
                                            {
                                                // Show a message.
                                                this.textBoxOutput.AppendText("Processing file \'{0}\'... ".FormatWith(zipEntry.Name));
                                            });

                                        try
                                        {
                                            // Extract the file entry to the specified file.
                                            zipEntry.ExtractToFile(tempFileName, true);

                                            // Parse the file.
                                            Locale locale = this.Parse(tempFileName);

                                            // Add the locale to the collection.
                                            localeCollection.Add(locale);

                                            this.Invoke(() =>
                                                {
                                                    this.textBoxOutput.AppendText("OK {0}".FormatWith(Environment.NewLine));
                                                });
                                        }
                                        catch (Exception ex)
                                        {
                                            this.Invoke(() =>
                                                {
                                                    this.textBoxOutput.AppendText("FAIL {0}{1}".FormatWith(ex.Message, Environment.NewLine));
                                                });
                                        }
                                        finally
                                        {
                                            try
                                            {
                                                // Delete the file.
                                                File.Delete(tempFileName);
                                            }
                                            catch { }
                                        }
                                    }

                                    this.Invoke(() =>
                                        {
                                            // Save the locale collection to a resource file.
                                            if (this.saveFileDialog.ShowDialog(this) == DialogResult.OK)
                                            {
                                                try
                                                {
                                                    using (FileStream file = new FileStream(this.saveFileDialog.FileName, FileMode.Create))
                                                    {
                                                        using (LocaleWriter writer = new LocaleWriter(file))
                                                        {
                                                            writer.WriteLocaleCollection(localeCollection);
                                                        }
                                                    }
                                                }
                                                catch (Exception exception)
                                                {
                                                    this.textBoxOutput.AppendText("Error: {0}".FormatWith(exception.Message));
                                                }

                                                // Create a resource writer for the specified file.
                                                //using (ResXResourceWriter resx = new ResXResourceWriter(this.saveFileDialog.FileName))
                                                //{
                                                //	//  Serialize the locale collection.
                                                //	resx.AddResource("LocaleCollection", localeCollection);
                                                //}
                                            }
                                        });
                                }
                            }
                        }
                        catch (Exception exception)
                        {
                            this.Invoke(() =>
                                {
                                    this.textBoxOutput.AppendText("Error: {0}".FormatWith(exception.Message));
                                });
                        }
                        finally
                        {
                            this.Invoke(() =>
                                {
                                    // Enable the controls.
                                    this.buttonLoad.Enabled = true;
                                    this.textBoxLocales.Enabled = true;
                                });
                        }
                    });
            }
        }
示例#7
0
        /// <summary>
        /// Reads a locale collection.
        /// </summary>
        /// <returns>The locale collection.</returns>
        public LocaleCollection ReadLocaleCollection()
        {
            // The XML document.
            XDocument document;

            // Load the XML document.
            if (null != this.reader)
                document = XDocument.Load(this.reader);
            else
                document = XDocument.Load(this.stream);

            // Create the locale collection.
            LocaleCollection locales = new LocaleCollection(
                document.Root.Elements("Locale").Select((XElement localeElement) =>
                    {
                        XElement cultureElement = localeElement.Element("Culture");
                        XAttribute languageAttribute = cultureElement.Attribute("Language");
                        XAttribute scriptAttribute = cultureElement.Attribute("Script");
                        XAttribute territoryAttribute = cultureElement.Attribute("Territory");
                        return new Locale(new CultureId(
                            languageAttribute.Value,
                            scriptAttribute != null ? scriptAttribute.Value : null,
                            territoryAttribute != null ? territoryAttribute.Value : null
                            ),
                            localeElement.Element("Languages").Elements("Language").Select((XElement languageElement) =>
                                {
                                    return new Language(languageElement.Attribute("Type").Value, languageElement.Value);
                                }),
                            localeElement.Element("Scripts").Elements("Script").Select((XElement scriptElement) =>
                                {
                                    return new Script(scriptElement.Attribute("Type").Value, scriptElement.Value);
                                }),
                            localeElement.Element("Territories").Elements("Territory").Select((XElement territoryElement) =>
                                {
                                    return new Territory(territoryElement.Attribute("Type").Value, territoryElement.Value);
                                }));
                    }));

            // Return the collection.
            return locales;
        }
示例#8
0
        /// <summary>
        /// Writes the specified locale collection.
        /// </summary>
        /// <param name="locales">The locale collection.</param>
        public void WriteLocaleCollection(LocaleCollection locales)
        {
            // Create the XML document.
            XDocument document = new XDocument(
                new XElement("Locales",
                    from locale in locales select new XElement("Locale",
                        new XElement("Culture",
                            new XAttribute("Language", locale.Culture.Language),
                            locale.Culture.Script != null ? new XAttribute("Script", locale.Culture.Script) : null,
                            locale.Culture.Territory != null ? new XAttribute("Territory", locale.Culture.Territory) : null),
                        new XElement("Languages",
                            from language in locale.Languages select new XElement("Language",
                                new XAttribute("Type", language.Type),
                                language.Name)),
                        new XElement("Scripts",
                            from script in locale.Scripts select new XElement("Script",
                                new XAttribute("Type", script.Type),
                                script.Name)),
                        new XElement("Territories",
                            from territory in locale.Territories select new XElement("Territory",
                                new XAttribute("Type", territory.Type),
                                territory.Name)))));

            // Write the document.
            if (null != this.writer)
                document.Save(writer);
            else
                document.Save(stream);
        }