Sign in to follow this  
Wessley Mitchell

.resx Resource Files Not Using Thread.CurrentThread.CurrentUICulture

Recommended Posts

Please see this example project:

https://1drv.ms/u/s!AvTC3qfYkjI9mqwxDmg5VFDpKlmuEg

Specifically, see the SimpleResource.cs file:

using GTANetworkAPI;
using System;
using System.Globalization;
using System.Threading;

namespace ResXTest
{
    class SimpleResource : Script
    {
        public SimpleResource()
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-ES");
            Console.WriteLine(Messages.Greeting);
        }
    }
}

When the project is run outside of Rage Multiplayer, "Hola" is written to the console.  When it is run within Rage Multiplayer, "Hello" is written to the console.  The "Messages" class is generated from a .resx file, and its output should vary based on CurrentUICulture.  The project contains Messages.resx and Messages.es-ES.resx.  But Rage always seems to use the default .resx file.

I discovered this bug while working with Wired Players.  Below, Xabi seems to blame the issue on .NET Core, but as my example proves, it's not quite that simple.  When this code is executed as a .NET Core console application, the output is correct.  It's only when run in conjunction with Rage Multiplayer that the discrepancy occurs.

https://rage.mp/forums/topic/1310-gamemode-wiredplayers-roleplay-server/?do=findComment&comment=15710

I would appreciate anyone's thoughts on how this can be rectified.  Thank you.

Share this post


Link to post
Share on other sites

That's a .NET Core bug which was fixed on 2.1, but the bridge is built with 2.0.7 currently.

Share this post


Link to post
Share on other sites
Posted (edited)

@Xabi, thank you for your response.  I'm not sure how you determined that.  I ran the code as .NET Core 2.0, .NET Core 2.1, and .NET Core 2.2 outside of Rage, and the output was correct.  Just for the heck of it, I copied the .NET Core 2.2 DLLs (including System.Resources.ResourceManager, which is where I would guess the problem would lie if it were a .NET Core bug), and the output was still incorrect.  I also could find nothing online about .NET Core 2.0.7 having trouble with resource cultures.

But either way, I expect you understand much more about Rage Multiplayer than I, and I thank you for your time.  Thank you also for making Wired Players.  [Message edited.  I've written you privately.]

Edited by Wessley Mitchell

Share this post


Link to post
Share on other sites
9 hours ago, Wessley Mitchell said:

@Xabi, thank you for your response.  I'm not sure how you determined that.  I ran the code as .NET Core 2.0, .NET Core 2.1, and .NET Core 2.2 outside of Rage, and the output was correct.  Just for the heck of it, I copied the .NET Core 2.2 DLLs (including System.Resources.ResourceManager, which is where I would guess the problem would lie if it were a .NET Core bug), and the output was still incorrect.  I also could find nothing online about .NET Core 2.0.7 having trouble with resource cultures.

But either way, I expect you understand much more about Rage Multiplayer than I, and I thank you for your time.  Thank you also for making Wired Players.  [Message edited.  I've written you privately.]

It was literally the first search from google when i typed "netcore 2.0 resx": https://github.com/dotnet/core/issues/1036

Share this post


Link to post
Share on other sites

Thank you.  I typed a much more specific query, and I didn't find that.  Also, from what I can see, that issue was never confirmed to be a bug in .NET Core.  The issue was moved elsewhere, and it was never reproduced and proven to be a bug--again, as far as I can see.  And as I pointed out in my original post, I couldn't reproduce it in .NET Core 2.0, 2.1, or 2.2.

But since the author of Wired Players, Xabi, has elsewhere said to rename .resx files to force it work for your culture, that's what I'm doing for now.  Thanks again.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.