public static bool IsPartiallyTranslated(this ActionModel actionModel, ILocalizer localizer) { actionModel.ThrowIfNotLocalizedModel(localizer); ActionModel originalActionModel = actionModel.GetOriginalModel(localizer); originalActionModel.ThrowIfNotModelWithAttributeRoutes(localizer); return(actionModel.Selectors.Count > 0); }
protected virtual void TranslateActionRoute(ActionModel localizedActionModel, SelectorModel originalSelectorModel, string template, string culture) { Logger.LogDebug( $"Add translated selector for action {localizedActionModel.Controller.ControllerName}:{localizedActionModel.ActionName} with \"{template}\" ({culture})."); localizedActionModel.ThrowIfNotLocalizedModel(RouteTranslationConfiguration.Localizer); if (RouteTranslationConfiguration.ValidateUrl) { ValidateUrl(originalSelectorModel.AttributeRouteModel.Template, template); } // Don't add RoutePrefix twice if (RouteTranslationConfiguration.AddCultureAsRoutePrefix && !localizedActionModel.Controller .GetOriginalModel(RouteTranslationConfiguration.Localizer) .HasAttributeRoutes()) { template = RouteTranslationConfiguration.Localizer.ApplyRouteCulturePrefix(template, culture); } SelectorModel localizedSelectorModel = new SelectorModel(originalSelectorModel) { AttributeRouteModel = { Template = template, }, }; localizedActionModel.Selectors.Add(localizedSelectorModel); RouteTranslationConfiguration.OnActionRouteTranslated(this, new OnActionRouteTranslatedEventArgs() { OriginalActionModel = localizedActionModel.GetOriginalModel(RouteTranslationConfiguration.Localizer), LocalizedActionModel = localizedActionModel, OriginalSelectorModel = originalSelectorModel, LocalizedSelectorModel = localizedSelectorModel, }); }