示例#1
0
        public static FieldConverter ResolveFallbackLanguages(LanguagesConfig languages)
        {
            return((data, field) =>
            {
                if (field.Partitioning.Equals(Partitioning.Language))
                {
                    foreach (var languageCode in languages.AllKeys)
                    {
                        if (data.TryGetNonNull(languageCode, out _))
                        {
                            continue;
                        }

                        foreach (var fallback in languages.GetPriorities(languageCode))
                        {
                            if (data.TryGetNonNull(fallback, out var value))
                            {
                                data[languageCode] = value;
                                break;
                            }
                        }
                    }
                }

                return data;
            });
        }