Socket
Socket
Sign inDemoInstall

github.com/sgatev/g11n

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/sgatev/g11n


Version published
Created
Source

g11n

Join the chat at https://gitter.im/sgatev/g11n Build Status Coverage Status Go Report Card GoDoc MIT License

g11n /gopherization/ is an internationalization library inspired by GWT that offers:

  • Statically-typed message keys.
  • Parameterized messages.
  • Extendable message formatting.
  • Custom localization file format.
package main

import (
	"fmt"
	"net/http"

	"github.com/sgatev/g11n"
	locale "github.com/sgatev/g11n/http"
)

type Messages struct {
	Hello func(string) string `default:"Hi %v!"`
}

func main() {
	http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) {
		// Create messages factory.
		factory := g11n.New()

		// Initialize messages value.
		var m Messages
		factory.Init(&m)

		// Set messages locale.
		locale.SetLocale(factory, r)

		fmt.Fprintf(w, m.Hello("World"))
	})

	log.Fatal(http.ListenAndServe(":8080", nil))
}

FAQs

Package last updated on 11 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc