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

Custom dialect resource files not loaded and shown as expected #376

Closed
Ronzan opened this issue Jan 7, 2021 · 4 comments
Closed

Custom dialect resource files not loaded and shown as expected #376

Ronzan opened this issue Jan 7, 2021 · 4 comments

Comments

@Ronzan
Copy link

Ronzan commented Jan 7, 2021

Not sure if this is a bug or by design.
My issue is that we have custom dialects in our project.
That is, we have .resx files with custom language codes like: en-GB-dev or en-GB-x-abc.
These custom dialect files are seen as separate resources and not as different languages.

ResXResourceManager:
image

This is apparently also an issue for VS, this is the folder in the project:
image

To Reproduce
Add two resource files with standard dialects, en-GB and en-US
Add a resource file with a custom dialects, en-GB-dev
Open ResXResourceManager and observe.

Expected behavior
I expected ResXResourceManager to show custom dialects the same way it shows standard dialects.

Is this an issue with ResXResourceManager, .NET, VS or what? :-)

@tom-englert
Copy link
Collaborator

Currently RXRM considers only languages known by Windows (anything returned by CultureInfo.GetCultures(CultureTypes.AllCultures)):

public static bool IsValidLanguageName(string? languageName)
{
if (languageName.IsNullOrEmpty())
return false;
return Array.BinarySearch(_sortedCultureNames, languageName, StringComparer.OrdinalIgnoreCase) >= 0;
}
private static string[] GetSortedCultureNames()
{
var allCultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
var pseudoLocales = new[] { "qps-ploc", "qps-ploca", "qps-plocm", "qps-Latn-x-sh" };
var cultureNames = allCultures
.SelectMany(culture => new[] { culture.IetfLanguageTag, culture.Name })
.Concat(pseudoLocales)
.Distinct()
.ToArray();
Array.Sort(cultureNames, StringComparer.OrdinalIgnoreCase);
return cultureNames;
}

Maybe you have a better approach?

@Ronzan
Copy link
Author

Ronzan commented Jan 8, 2021

I haven't looked over the source much yet, and I haven't found where the resx files are actually loaded.
I think the .GetCultures() makes good sense for the list of languages, I don't see a better option for that.
I'll see if I can find where RXRM is deciding what files to load :)

@tom-englert
Copy link
Collaborator

Actually the files will be loaded. However since en-GB-dev is not detected as a valid language name, it is treated as the neutral culture of the SharedResource.en-GB-dev, not as a specific culture of SharedResource

@tom-englert tom-englert added this to the 1.49 milestone Jan 16, 2021
@Ronzan
Copy link
Author

Ronzan commented Jan 18, 2021

Thank you very much @tom-englert, it works perfectly :)
Much appreciated.

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

2 participants