blazored / localisation Goto Github PK
View Code? Open in Web Editor NEWA library to provide localisation in client-side Blazor applications
License: MIT License
A library to provide localisation in client-side Blazor applications
License: MIT License
When I publish my CSB app, just using the VS publish wizard on my project and publishing to a folder, the 'Blazored.Localisation' folder ends up under 'bin\Release\netstandard2.0\publish\wwwroot\_content' which seems kind of logical based on the publish profile but I was expecting it to end up in 'bin\Release\netstandard2.0\publish<app-name>\dist\_content' along with everything else that I can just copy to my hosting location.
The other library js files that I'm using end up under the dist folder, so I was wondering why this library was different, resulting in me having to remember to copy the files separately.
My publish profile looks like this:
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>da48448a-b9da-483f-81c1-81c882f5f773</ProjectGuid>
<publishUrl>bin\Release\netstandard2.0\publish\</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>
For wiring up Blazored.Localisation in Program.cs there is:
builder.Services.AddBlazoredLocalisation();
And
host.InitializeBlazoredLocalization();
localisation (British English) vs localization (American English). Shouldn't we pick one?
Hi,
I am using this approach for setting the culture in my blazor app. I have a DateTime
property that is bound to an input field. The initial load is with the correct Culture. If I then change the value of the input field the Culture gets reset to the default culture and the date is formatted incorrectly.
Any idea how to solve that?
Is it possible to modify the library to make the language selectable inside the app? Relying on browser culture is not always the best way.
It is possible to make BrowserDateTimeProvider.GetInstance fail and the culprit seems to be the call to getTimezoneOffset. It has never done this with normal usage but I can lay out the way to do it consistently.
I started using Serilog on the client (you can follow the instructions here) https://github.com/serilog/serilog/wiki/Getting-Started And note the call to the logger made in Program.cs Log.Information("Hello, world!"); With that present the call to GetInstance (above) throws an exception. I comment that out and it works normally.
I have a work-around I wrap
timeZoneOffSet = await _jsRuntime.InvokeAsync("eval", "new Date().getTimezoneOffset()");
in a try/catch and upon failure simply call it again. The second call succeeds.
I don't understand how the two could be interacting but something is up. I used your repo as is and upgraded to Core 3.1 with the same results.
ultureInfo.DefaultThreadCurrentCulture = culture;
This actually changes the culture for all users that have some blazor page already open.
In this line: host.InitializeBlazoredLocalization();
I am getting this error:
'WebAssemblyHost' does not contain a definition for 'InitializeBlazoredLocalization' and no accessible extension method 'InitializeBlazoredLocalization' accepting a first argument of type 'WebAssemblyHost' could be found (are you missing a using directive or an assembly reference?)
I am using your settings but I have this error. Do you have any idea why?
The latest version of Blazor is causing an issue. I updated the libraries, changed the target to 2.1 and tried to run the demo.
WASM: System.AggregateException: One or more errors occurred. (Could not find 'blazoredLocalisation' in 'window'.blazor.webassembly.js:1
WASM: Error: Could not find 'blazoredLocalisation' in 'window'.
Per our conversation a script tag is now required and adding the following fixes everything.
<script src="_content/Blazored.Localisation/blazored-localisation.js"></script>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.