private static void LoadVocabulariesForLocalization(Localization loc)
        {
            string key      = loc.LocalizationId;
            string url      = Path.Combine(loc.Path.ToCombinePath(true), SiteConfiguration.SystemFolder, @"mappings\vocabularies.json").Replace("\\", "/");
            string jsonData = SiteConfiguration.ContentProvider.GetStaticContentItem(url, loc).GetText();

            if (jsonData != null)
            {
                List <SemanticVocabulary> vocabs = GetVocabulariesFromFile(jsonData);
                SiteConfiguration.ThreadSafeSettingsUpdate(_vocabSettingsType, _semanticVocabularies, key, vocabs);
            }
        }
        private static void LoadSemanticMapForLocalization(Localization loc)
        {
            string key      = loc.LocalizationId;
            string url      = Path.Combine(loc.Path.ToCombinePath(true), SiteConfiguration.SystemFolder, @"mappings\schemas.json").Replace("\\", "/");
            string jsonData = SiteConfiguration.ContentProvider.GetStaticContentItem(url, loc).GetText();;

            if (jsonData != null)
            {
                IEnumerable <SemanticSchema>        schemas = GetSchemasFromFile(jsonData);
                Dictionary <string, SemanticSchema> map     = new Dictionary <string, SemanticSchema>();
                foreach (SemanticSchema schema in schemas)
                {
                    schema.Localization = loc;
                    map.Add(schema.Id.ToString(CultureInfo.InvariantCulture), schema);
                }
                SiteConfiguration.ThreadSafeSettingsUpdate(_mapSettingsType, _semanticMap, key, map);
            }
        }
Beispiel #3
0
        private static void LoadResourcesForLocalization(Localization loc)
        {
            Log.Debug("Loading resources for localization : {0}", loc.LocalizationId);
            string key = loc.LocalizationId;
            Dictionary <string, object> resources = new Dictionary <string, object>();
            string url      = Path.Combine(loc.Path.ToCombinePath(true), SiteConfiguration.SystemFolder, @"resources\_all.json").Replace("\\", "/");
            string jsonData = SiteConfiguration.ContentProvider.GetStaticContentItem(url, loc).GetText();

            if (jsonData != null)
            {
                //The _all.json file contains a list of all other resources files to load
                dynamic bootstrapJson = Json.Decode(jsonData);
                foreach (string resourceUrl in bootstrapJson.files)
                {
                    string type = resourceUrl.Substring(resourceUrl.LastIndexOf("/", StringComparison.Ordinal) + 1);
                    type     = type.Substring(0, type.LastIndexOf(".", StringComparison.Ordinal)).ToLower();
                    jsonData = SiteConfiguration.ContentProvider.GetStaticContentItem(resourceUrl, loc).GetText();
                    if (jsonData != null)
                    {
                        Log.Debug("Loading resources from file: {0}", resourceUrl);
                        foreach (KeyValuePair <string, object> item in GetResourcesFromFile(jsonData))
                        {
                            //we ensure resource key uniqueness by adding the type (which comes from the filename)
                            resources.Add(String.Format("{0}.{1}", type, item.Key), item.Value);
                        }
                    }
                    else
                    {
                        Log.Error("Resource file: {0} does not exist for localization {1} - skipping", resourceUrl, key);
                    }
                }
                SiteConfiguration.ThreadSafeSettingsUpdate <Dictionary <string, object> >(_settingsType, _resources, key, resources);
            }
            else
            {
                Log.Error("Localization resource bootstrap file: {0} does not exist for localization {1}. Check that the Publish Settings page has been published in this publication.", url, loc.LocalizationId);
            }
        }