i18nexample

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MPL-2.0 Imports: 2 Imported by: 0

README

i18n Example

This example shows the first localization slice:

  • gowdk.config.go declares Config.I18N locales.
  • messages.go keeps typed message keys and catalogs in normal Go.
  • messages_test.go checks the required typed message keys against each locale catalog without hand-maintained source line metadata.
  • home.page.gwdk calls a Go build helper that reads gowdk.BuildParams.LocaleCode().

Build it from the repository root:

go run ./cmd/gowdk build --config examples/i18n/gowdk.config.go --out /tmp/gowdk-i18n-build examples/i18n/*.gwdk
test -f /tmp/gowdk-i18n-build/en/index.html
test -f /tmp/gowdk-i18n-build/pt/index.html
grep -F '<html lang="en">' /tmp/gowdk-i18n-build/en/index.html
grep -F '<html lang="pt">' /tmp/gowdk-i18n-build/pt/index.html
go test ./examples/i18n

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Config = gowdk.Config{
	AppName: "gowdk-i18n-example",
	Source: gowdk.SourceConfig{
		Include: []string{"examples/i18n/*.gwdk"},
	},
	CSS: gowdk.CSSConfig{
		Include: []string{"examples/i18n/*.css"},
	},
	I18N: gowdk.I18NConfig{
		DefaultLocale: localeEnglish,
		Locales: []gowdk.LocaleConfig{
			{Code: localeEnglish, Name: "English"},
			{Code: localePortuguese, Name: "Portuguese"},
		},
	},
}

Functions

This section is empty.

Types

type HomeCopy

type HomeCopy struct {
	Title string `json:"title"`
	Intro string `json:"intro"`
}

func HomeCopyForBuild

func HomeCopyForBuild(params gowdk.BuildParams) HomeCopy

Jump to

Keyboard shortcuts

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