Jump to content

.resx Resource Files Not Using Thread.CurrentThread.CurrentUICulture


Recommended Posts

Posted

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.

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
Posted
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

Posted

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...