public string[] GetGlobalFileLocations(CultureInfo culture)
        {
            var cultureSuffix = "." + culture.Name;

            cultureSuffix = cultureSuffix == "." ? string.Empty : cultureSuffix;

            if (LocalizerUtil.IsChildCulture(DefaultCulture.UICulture, culture) || LocalizerUtil.IsChildCulture(culture, DefaultCulture.UICulture))
            {
                cultureSuffix = string.Empty;
            }

            var cacheName = "global";

            cacheName += string.IsNullOrEmpty(cultureSuffix) ? ".default" : cultureSuffix;

            string root = _app.ContentRootPath;

            if (!string.IsNullOrEmpty(ResourceRelativePath))
            {
                root = Path.Combine(root, ResourceRelativePath.Trim('/', '\\'));
            }

            var resourceBaseName      = GlobalName;
            var resourceFileLocations = LocalizerUtil.ExpandPaths(resourceBaseName, _app.ApplicationName).ToList();

            return(resourceFileLocations.Select(resourceFileLocation => resourceFileLocation + cultureSuffix + ".json")
                   .Select(resourcePath => Path.Combine(root, resourcePath))
                   .ToArray());
        }
        public string[] GetAreaFileLocations(CultureInfo culture, string areaName)
        {
            if (string.IsNullOrEmpty(areaName?.Trim()))
            {
                throw new ArgumentNullException(nameof(areaName));
            }

            var cultureSuffix = "." + culture.Name;

            cultureSuffix = cultureSuffix == "." ? string.Empty : cultureSuffix;

            if (LocalizerUtil.IsChildCulture(DefaultCulture.UICulture, culture) || LocalizerUtil.IsChildCulture(culture, DefaultCulture.UICulture))
            {
                cultureSuffix = string.Empty;
            }

            var areaSuffix = $".{areaName}";

            var cacheName = $"{AreaName}{areaSuffix}";

            cacheName += string.IsNullOrEmpty(cultureSuffix) ? ".default" : cultureSuffix;

            string root = _app.ContentRootPath;

            if (!string.IsNullOrEmpty(ResourceRelativePath))
            {
                root = Path.Combine(root, ResourceRelativePath.Trim('/', '\\'));
            }

            var resourceBaseName      = AreaName;
            var resourceFileLocations = LocalizerUtil.ExpandPaths(resourceBaseName, _app.ApplicationName).ToList();

            return(resourceFileLocations.Select(resourceFileLocation => resourceFileLocation + areaSuffix + cultureSuffix + ".json")
                   .Select(resourcePath => Path.Combine(root, resourcePath))
                   .ToArray());
        }
        public JsonDocument GetAreaResources(CultureInfo culture, string areaName)
        {
            if (string.IsNullOrEmpty(areaName?.Trim()))
            {
                throw new ArgumentNullException(nameof(areaName));
            }

            var cultureSuffix = "." + culture.Name;

            cultureSuffix = cultureSuffix == "." ? string.Empty : cultureSuffix;

            if (LocalizerUtil.IsChildCulture(DefaultCulture.UICulture, culture) || LocalizerUtil.IsChildCulture(culture, DefaultCulture.UICulture))
            {
                cultureSuffix = string.Empty;
            }

            var areaSuffix = $".{areaName}";

            var cacheName = $"{AreaName}{areaSuffix}";

            cacheName += string.IsNullOrEmpty(cultureSuffix) ? ".default" : cultureSuffix;

            var lazyJObjectGetter = new Lazy <JsonDocument>(
                () =>
            {
                _logger.LogDebug_Localizer($"Resource file content not found in cache ({cacheName}), try to load from file.");

                string root = _app.ContentRootPath;

                if (!string.IsNullOrEmpty(ResourceRelativePath))
                {
                    root = Path.Combine(root, ResourceRelativePath.Trim('/', '\\'));
                }

                _logger.LogDebug_Localizer($"Looking for resource files in {root}");

                var resourceBaseName      = AreaName;
                var resourceFileLocations = LocalizerUtil.ExpandPaths(resourceBaseName, _app.ApplicationName).ToList();

                string resourcePath = null;
                foreach (var resourceFileLocation in resourceFileLocations)
                {
                    resourcePath = resourceFileLocation + areaSuffix + cultureSuffix + ".json";
                    resourcePath = Path.Combine(root, resourcePath);

                    if (File.Exists(resourcePath))
                    {
                        _logger.LogDebug_Localizer($"Resource file found: {resourcePath}");
                        break;
                    }
                    else
                    {
                        _logger.LogDebug_Localizer($"Resource file not found: {resourcePath}");
                        resourcePath = null;
                    }
                }

                if (resourcePath == null)
                {
                    _logger.LogWarning_Localizer($"There is no resource file found for {resourceBaseName}");
                    return(null);
                }

                try
                {
                    var resourceFileStream = new FileStream(resourcePath, FileMode.Open, FileAccess.Read, FileShare.Read, 4096, FileOptions.Asynchronous | FileOptions.SequentialScan);
                    using (resourceFileStream)
                    {
                        var content = JsonDocument.Parse(resourceFileStream);

                        _logger.LogInformation_Localizer($"Resource file content loaded: {resourcePath}");

                        return(content);
                    }
                }
                catch (Exception ex)
                {
                    _logger.LogError_Localizer(ex, $"Error while loading resource file: {ex.Message} ({resourcePath})");
                    return(null);
                }
            }, LazyThreadSafetyMode.ExecutionAndPublication);

            _logger.LogInformation_Localizer($"Trying to load resource file content from cache {cacheName}.");

            lazyJObjectGetter = _resources.GetOrAdd(cacheName, lazyJObjectGetter);
            return(lazyJObjectGetter.Value);
        }