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

Date(Time) of versions is not globalized #58

Open
FroggieFrog opened this issue Feb 2, 2024 · 5 comments
Open

Date(Time) of versions is not globalized #58

FroggieFrog opened this issue Feb 2, 2024 · 5 comments
Labels
bug Something isn't working no-issue-activity

Comments

@FroggieFrog
Copy link

Describe the bug

The detail page for a package does not use a globalized representation as requested by the browser.

To Reproduce

  1. open a detail page
  2. look at the Versions section in the Last Updated column

Expected behavior

A globalized representation as requested by the browser.

Screenshots

hosted as docker container
package_detail_docker

running local
package_detail_local

Additional context

It seems as the docker hosted version does not check the request header.
I added the following code to the Package.cshtml file.

@using System.Globalization;
    
<p>
    <b>CurrentCulture</b>: @System.Globalization.CultureInfo.CurrentCulture   
</p>
<p>
    <b>AcceptLanguage Header</b>: @HttpContext.Request.Headers.AcceptLanguage.ToString();
</p>
<p>
    <b>Last updated (ToShortDateString)</b>: @Model.Versions[0].LastUpdated.ToShortDateString();
</p>
@seriouz
Copy link

seriouz commented Feb 4, 2024

Did you set the wished timezone to the Docker container as environment variable like so

docker run -p 5000:8080 -e TZ=Europe/Berlin bagetter/bagetter

or does this never work in Docker?

@FroggieFrog
Copy link
Author

FroggieFrog commented Feb 5, 2024

I did not know about this feature....
But that also does not fix the issue.
In my tests it never worked, when hosted inside of Docker.

@Regenhardt
Copy link

Unfortunately, even with the new Dockerfile it looks like this for me:

CurrentCulture:

AcceptLanguage Header: de,en-GB;q=0.7,en;q=0.3;

Last updated (ToShortDateString): 02/12/2024; 

Putting something like this in the request pipeline works correctly in my small test, but I'm not entirely sure what else is affected by that and also it feels like the framework should already do something like this for us:

    app.Use(async (context, next) =>
    {
        var preferredLanguage = context.Request.Headers["Accept-Language"].ToString().Split(',').FirstOrDefault();
        if (!string.IsNullOrEmpty(preferredLanguage))
        {
            var culture = new System.Globalization.CultureInfo(preferredLanguage);
            System.Globalization.CultureInfo.CurrentCulture = culture;
        }

        await next.Invoke();
    });

@Regenhardt Regenhardt added the bug Something isn't working label Feb 29, 2024
Copy link

This issue is stale because it has been open for 90 days with no activity. Remove the stale label, comment, or this will be closed in 5 days.

Copy link

github-actions bot commented Jun 4, 2024

This issue was closed because it has been stale for 5 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 4, 2024
@Regenhardt Regenhardt reopened this Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working no-issue-activity
Projects
None yet
Development

No branches or pull requests

3 participants