Giter Club home page Giter Club logo

simple-go-i18n-demo's Introduction

A simple demo of a Go application that runs a server that renders some templates.

  • Template engine is extemplate which is built on top of Go's html/template library to allow extending base templates.
  • Chi was used as the webserver because it's idiomatic and has great utilities (IMO). I used this over the plain http library since it already has the concept of middleware, route params and contains a router.
  • The i18n was rolled as an example implementation. The implementation is a bit cumbersome for a large amount of usage but it gets the point across.

To see the demo in practice, clone this repo somewhere (it's go modules so you probably still need the GO111MODULE var set and it does not necessarly need to go in $GOPATH/src).

Once downloaded just run go build then ./http-server and you can visit / which should render Index Page (in all "locales"), /home which should render "Home Page" or "Página de inicio" in Spanish, and finally /hello/{name} (where {name} is a name, like /hello/Brandon) which should render "Hello, {name}!" or "¡Hola, {name}!" depending on locale.

To change locales just add a query string ?locale=es and you should see the changes on home/hello pages. es is the only locale hardcoded so you can simply add a new one to the localeMap and then use it on subsequent builds for testing purposes.

simple-go-i18n-demo's People

Contributors

bbuck avatar

Watchers

thefish avatar James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.