Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n in StatusConditionView and StatusBrowser #4266

Open
easyworld opened this issue May 8, 2024 · 0 comments
Open

i18n in StatusConditionView and StatusBrowser #4266

easyworld opened this issue May 8, 2024 · 0 comments

Comments

@easyworld
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Yes, I'm currently facing a problem with the StatusConditionView and StatusBrowser classes in our application. They do not support internationalization (i18n), which is limiting our ability to deploy our software effectively in multiple linguistic regions. Users from non-English speaking countries find it difficult to interact with these components, leading to a less user-friendly experience.

Describe the solution you'd like
To handle the internationalization of enums used within these classes effectively, we can implement a method like the following (copied from here):

public string[] LocalizeEnum<T>() where T : struct, Enum
{
    var type = typeof(T);
    var names = Enum.GetNames<T>();
    var result = new string[names.Length];
    for (int i = 0; i < result.Length; i++)
        result[i] = Localize($"{type.Name}.{names[i]}", names[i]);
    return result;
}

private string Localize(string key, string fallback)
{
    if (Others.TryGetValue(key, out var value))
        return value;
    Others.Add(key, fallback);
    return fallback;
}

This method would dynamically translate enum names based on the current locale, enabling a more tailored user interface across different regions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant