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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
i18nc command

Jump to

Keyboard shortcuts

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