turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 155 forks source link

Javascript localization not working because browser cache #408

Closed alexvazquez closed 3 years ago

alexvazquez commented 3 years ago

I have a ASP.NET MVC 4 C# web application where I already implement i18 successfully on HTML and Javascript file. I just did this for the first page for testing and working well. This page has a form with javascript custom validation messages.

The first time the application loads the language is English so the validation messages on the javascript file are in english. Then I change the language from menu to be Spanish and all the text in the HTML is localized except the javascript validation messages and this is due to the browser cache. I'm using Bundle & minification and just disable it to try if adding a random versioning to the end of the javascript file works but it doesnt.


@section FooterScripts{

    @{ 
        Random random = new Random();

        const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        string version = new string(Enumerable.Repeat(chars, 6)
          .Select(s => s[random.Next(s.Length)]).ToArray());
    }

    @*@Scripts.Render("~/bundles/loginjs")*@
    <script src="~/Scripts/js/login.js?v=@version"></script>
}

The above code doesn't work, actually, the page didn't load and I guess this conflicts with how the i18 tries to find the file and do the localization.

Anyway, does anyone know if i118 has any property or configuration so translation on javascript files works even with browser caching thing? Appreciate it

turquoiseowl commented 3 years ago

Let's continue this at #226