Open Closed

Bug in Localization logic causes feature management to fail #8169


User avatar
0
ahmednfwela@bdaya-dev.com created

The bug described here: https://github.com/abpframework/abp/issues/21191

Is causing our production app to fail Please provide us with a workaround until it's fixed

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

5 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Thanks. I will check it asap.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you try to replace the ILocalizableStringSerializer with MyLocalizableStringSerializer?

    if (value.IsNullOrEmpty())
    {
        return new FixedLocalizableString(string.Empty);
    }
    
    if (value.Length < 3 ||
        value[1] != ':')
    {
        return new FixedLocalizableString(value);
    }
    
    using System;
    using Microsoft.Extensions.Options;
    using Volo.Abp.DependencyInjection;
    
    namespace Volo.Abp.Localization;
    
    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(ILocalizableStringSerializer))]
    public class MyLocalizableStringSerializer : ILocalizableStringSerializer, ITransientDependency
    {
        protected AbpLocalizationOptions LocalizationOptions { get; }
    
        public MyLocalizableStringSerializer(IOptions<AbpLocalizationOptions> localizationOptions)
        {
            LocalizationOptions = localizationOptions.Value;
        }
    
        public virtual string? Serialize(ILocalizableString? localizableString)
        {
            if (localizableString == null)
            {
                return null;
            }
    
            if (localizableString is LocalizableString realLocalizableString)
            {
                return $"L:{realLocalizableString.ResourceName},{realLocalizableString.Name}";
            }
    
            if (localizableString is FixedLocalizableString fixedLocalizableString)
            {
                return $"F:{fixedLocalizableString.Value}";
            }
    
            throw new AbpException($"Unknown {nameof(ILocalizableString)} type: {localizableString.GetType().FullName}");
        }
    
        public virtual ILocalizableString Deserialize(string value)
        {
            if (value.IsNullOrEmpty())
            {
                return new FixedLocalizableString(string.Empty);
            }
    
            if (value.Length < 3 ||
                value[1] != ':')
            {
                return new FixedLocalizableString(value);
            }
    
            var type = value[0];
            switch (type)
            {
                case 'F':
                    return new FixedLocalizableString(value.Substring(2));
                case 'L':
                    var commaPosition = value.IndexOf(',', 2);
                    if (commaPosition == -1)
                    {
                        throw new AbpException("Invalid LocalizableString value: " + value);
                    }
    
                    var resourceName = value.Substring(2, commaPosition - 2);
                    var name = value.Substring(commaPosition + 1);
                    if (name.IsNullOrWhiteSpace())
                    {
                        throw new AbpException("Invalid LocalizableString value: " + value);
                    }
    
                    return LocalizableString.Create(name, resourceName);
                default:
                    return new FixedLocalizableString(value);
            }
        }
    }
    
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    ahmednfwela@bdaya-dev.com created

    I am using this right now and it solves my issue:

    [Dependency(ReplaceServices = true)]
    [ExposeServices(typeof(LocalizableStringSerializer), typeof(ILocalizableStringSerializer), typeof(FixedLocalizableStringSerializer))]
    public class FixedLocalizableStringSerializer(IOptions<AbpLocalizationOptions> localizationOptions) : LocalizableStringSerializer(localizationOptions), ITransientDependency
    {
        public override ILocalizableString Deserialize(string? value)
        {
            if (value == null)
            {
                return new FixedLocalizableString("");
            }
            return base.Deserialize(value);
        }
    }
    

    is there a problem with my workaround ?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    No problem, Its same way.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    https://github.com/abpframework/abp/pull/21206

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.