Пример #1
0
        // return dict is: Identity -> locator
        private IDictionary <string, ILocalizationLocator> GetLocalizationsFromTemplates(IReadOnlyList <TemplateInfo> templateList, string locale)
        {
            IDictionary <string, ILocalizationLocator> locatorLookup = new Dictionary <string, ILocalizationLocator>();

            foreach (TemplateInfo template in templateList)
            {
                if (template.LocaleConfigMountPointId == null ||
                    template.LocaleConfigMountPointId == Guid.Empty)
                {   // Indicates an unlocalized entry in the locale specific template cache.
                    continue;
                }

                ILocalizationLocator locator = new LocalizationLocator()
                {
                    Locale       = locale,
                    MountPointId = template.LocaleConfigMountPointId,
                    ConfigPlace  = template.LocaleConfigPlace,
                    Identity     = template.Identity,
                    Author       = template.Author,
                    Name         = template.Name,
                    Description  = template.Description
                                   // ParameterSymbols are not needed here. If things get refactored too much, they might become needed
                };

                locatorLookup.Add(locator.Identity, locator);
            }

            return(locatorLookup);
        }
Пример #2
0
        private IDictionary <string, ILocalizationLocator> GetLocalizationsFromTemplates(IReadOnlyList <TemplateInfo> templateList,
                                                                                         string locale)
        {
            IDictionary <string, ILocalizationLocator> dictionary = new Dictionary <string, ILocalizationLocator>();

            foreach (TemplateInfo template in templateList)
            {
                Guid localeConfigMountPointId = template.LocaleConfigMountPointId;
                if (!(template.LocaleConfigMountPointId == Guid.Empty))
                {
                    ILocalizationLocator localizationLocator = new LocalizationLocator
                    {
                        Locale       = locale,
                        MountPointId = template.LocaleConfigMountPointId,
                        ConfigPlace  = template.LocaleConfigPlace,
                        Identity     = template.Identity,
                        Author       = template.Author,
                        Name         = template.Name,
                        Description  = template.Description
                    };
                    dictionary.Add(localizationLocator.Identity, localizationLocator);
                }
            }

            return(dictionary);
        }
Пример #3
0
        // return dict is: Identity -> locator
        private IDictionary <string, ILocalizationLocator> GetLocalizationsFromTemplates(IList <TemplateInfo> templateList, string locale)
        {
            IDictionary <string, ILocalizationLocator> locatorLookup = new Dictionary <string, ILocalizationLocator>();

            foreach (TemplateInfo template in templateList)
            {
                if (template.LocaleConfigMountPointId == null ||
                    template.LocaleConfigMountPointId == Guid.Empty)
                {   // Indicates an unlocalized entry in the locale specific template cache.
                    continue;
                }

                ILocalizationLocator locator = new LocalizationLocator()
                {
                    Locale       = locale,
                    MountPointId = template.LocaleConfigMountPointId,
                    ConfigPlace  = template.LocaleConfigPlace,
                    Identity     = template.Identity,
                    Author       = template.Author,
                    Name         = template.Name,
                    Description  = template.Description
                };

                locatorLookup.Add(locator.Identity, locator);
            }

            return(locatorLookup);
        }
Пример #4
0
        public void ReloadLocalization()
        {
            var localizationHandler         = ClientContainerLocator.Container.Resolve <ILocalizationHandler>();
            var clientConfigurationProvider = ClientContainerLocator.Container.Resolve <IClientConfigurationProvider>();
            var pacakgeService = ClientContainerLocator.Container.Resolve <IPackageService>();


            string loc = clientConfigurationProvider.LocalizationResourceFileName;

            var    serverPackage = Path.Combine(clientConfigurationProvider.PackageFolderPath, FileNameConstants.ServerPackageDescriptorFileName);
            string language      = "de";

            if (File.Exists(serverPackage))
            {
                var serverPackageDescriptor = pacakgeService.GetSeverpackageDescriptor(serverPackage);

                string newLanguage = serverPackageDescriptor.CurrentCulture.Substring(0, 2);
                string lng         = newLanguage.ToLower();

                if (new[] { "de", "it", "fr" }.Contains(lng))
                {
                    loc      = string.Format("{0}.{1}.resx", FileNameConstants.MobileLocalizationFileNameWithoutExtension, lng);
                    language = lng;
                }
            }

            string localizationResourceFileName = Path.Combine(clientConfigurationProvider.PackageFolderPath,
                                                               clientConfigurationProvider.LocalizationResourceDirectoryPath,
                                                               loc);

            if (!File.Exists(localizationResourceFileName))
            {
                localizationResourceFileName = clientConfigurationProvider.LocalizationResourceFilePath;
            }

            if (File.Exists(localizationResourceFileName))
            {
                LocalizationLocator.SetMobileLocalization(localizationHandler.ReadResourceFile(localizationResourceFileName));
            }
            else
            {
                Loggers.TechLogger.Warn(string.Format("Localization Resource file not found! ({0})", localizationResourceFileName));
            }

            CultureInfo currentCulture = CultureInfo.CreateSpecificCulture("de-CH");

            if (language != "de")
            {
                var newCulture = CultureInfo.CreateSpecificCulture(language + "-CH");
                newCulture.NumberFormat = currentCulture.NumberFormat;
                currentCulture          = newCulture;
            }
            currentCulture.NumberFormat.NumberDecimalSeparator = ".";
            currentCulture.NumberFormat.NumberGroupSeparator   = "'";
            Thread.CurrentThread.CurrentCulture   = currentCulture;
            Thread.CurrentThread.CurrentUICulture = currentCulture;

            if (!isLoaded)
            {
                isLoaded = true;
                FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
            }
            ((ResourceWrapper)Application.Current.Resources["Resx"]).Refresh();
        }