A very quick and dirty demonstration showing how localized strings can be toggled directly in the UI using Javascript in a decoupled fashion.
This simple PoC demonstrates how to get around some of the limitations in classic ASP.Net Web Forms when implementing modern, semantic, seo compliant and accessible websites. The approach is not new and simply decouples the front and back ends so that they communicate via an API.
In this demonstration project the front-end pages are served from the wwwroot folder under IIS. However, using this approach there is no reason that the pages cannot be deployed on a remote static server running Nginx, Node, Ruby, AWS S3, etc. This forces the .NET Core back-end into a strongly typed, robust and scalable API-only application.
While the demo shows how language/resource strings could be managed at the client level the principals can be applied to any aspect of the workflow of a modern web application.
Note that using Javascript to modify the locale content is fast and flicker free but may impact SEO value for all but the default locale. If SEO for all languages is required it would be preferrable to render separate language specific pages. While Google does a great job of crawling Javascript enabled sites no other search engines have this capability at the time of this writing.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- A contemporary development machine running a recent and stable version of Linux, Windows or OSX
- .Net Core 2.1.401
- A good code editor like Visual Studio Code or Visual Studio Professional
- Clone the repository
git clone repo
- Change to the cloned folder
cd
- Open up your code editor, e.g.
code .
- Compile and run the application , e.g.
F5
- Navigate to https://localhost:5001 in your brower. It has been barely tested in Google Chrome Version 68.0.3440.106 (Official Build) (64-bit).
- Observe there are two pages, home and about. Toggling language on the home page relies upon the built in JSON object where as the about page uses an API call to fetch the localisation data.
There are no tests in this PoC
This project is not intended to be deployed
- Coffee: A good source of C8H10N4O2
- README template
- Ubuntu 18.04
- Visual Studio Code v1.26.1
- .NET Core 2.1.401
We use SemVer for versioning.
- Troy Forster - Initial work - tforster
MIT