using System.Collections.Generic; using System.Linq; namespace QRRapidoApp.Models.Extensions { public static class PlanExtensions { public static string GetLocalizedName(this Plan plan, string languageCode) { if (plan.Name.TryGetValue(languageCode, out var name)) return name; // Fallback to Portuguese if language not found if (plan.Name.TryGetValue("pt-BR", out var ptName)) return ptName; // Final fallback to first available language return plan.Name.Values.FirstOrDefault() ?? "Plan"; } public static string GetLocalizedDescription(this Plan plan, string languageCode) { if (plan.Description.TryGetValue(languageCode, out var description)) return description; // Fallback to Portuguese if language not found if (plan.Description.TryGetValue("pt-BR", out var ptDescription)) return ptDescription; // Final fallback to first available language return plan.Description.Values.FirstOrDefault() ?? "Premium plan description"; } public static List GetLocalizedFeatures(this Plan plan, string languageCode) { if (plan.Features.TryGetValue(languageCode, out var features)) return features; // Fallback to Portuguese if language not found if (plan.Features.TryGetValue("pt-BR", out var ptFeatures)) return ptFeatures; // Final fallback to first available language return plan.Features.Values.FirstOrDefault() ?? new List(); } public static string GetLanguageCode(string culture) { return culture switch { "pt-BR" or "pt" => "pt-BR", "es" or "es-ES" => "es", "en" or "en-US" => "en", _ => "pt-BR" // Default to Portuguese }; } } }