i18nc

package module
v0.0.0-...-5aed5e9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2021 License: MIT Imports: 9 Imported by: 0

README

i18nc

Generate type safe Go code from english locale content

Usage

Create i18nc generate.go
# file i18nc/generate.go

package i18nc

//go:generate go run -mod=mod github.com/dcb9/i18nc/cmd/i18nc $GOPACKAGE i18nc_generated.go ../locales/en.json
generate Go code
$ go generate ./i18nc
Init i18nc and use
package main

import (
	"your_module/i18nc"
	"github.com/nicksnyder/go-i18n/v2/i18n"
)

func main() {
	i18nc.Localizer = initLocalizer()

	fmt.Println(i18nc.YourMessageID())
}

func initLocalizer() *i18n.Localizer {
	// FIXME: do your own init procedure
	return nil
}

Acknowledgements

License

Released under the MIT License - see LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromBytes

func FromBytes(content []byte, pkg string, w io.Writer) error

FromBytes generate type safe Go from locale file content

func FromFile

func FromFile(path string, pkg string, w io.Writer) error

FromFile generate type safe Go from locale file path

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL