dyntpl_i18n

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: MIT Imports: 5 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

Dyntpl i18n bindings

Provide i18n support to use in dyntpl templates.

Internationalization support provides by i18n package.

I18n enables by setup context with variables like this:

var db *i18n.DB
ctx := dyntpl.AcquireCtx()
defer dyntpl.ReleaseCtx(ctx)
ctx.SetStatic(dyntpl_i18n.DatabaseKey, db).
	SetString(dyntpl_i18n.LocaleKey, "en")
...

or by using shorthand

var db *i18n.DB
ctx := dyntpl_i18n.AcquireCtx("en", "ltr", db)
defer dyntpl_i18n.Release(ctx)
...

For simple translate use function i18n::template or shorthand i18n::t:

{%= i18n::t("key", "default value", {"!placeholder0": "replacement", "!placeholder1": object.Label, ...}) %}

You may omit default value and replacements, only first argument is required.

For plural translation use function i18n::translatePlural or shorthand i18n::tp:

{%= i18n::tp("key", "default value", 15, {...}) %}

Third argument is a count for a plural formula. It's required as a key argument.

Documentation

Index

Constants

View Source
const (
	DatabaseKey            = "i18n__database"
	PlaceholderReplacerKey = "i18n__placeholder"
	LocaleKey              = "i18n__locale"
	DirectionKey           = "i18n__direction"
)

Variables

This section is empty.

Functions

func AcquireCtx

func AcquireCtx(locale, direction string, db *i18n.DB) *dyntpl.Ctx

AcquireCtx takes ctx from default pool and wraps it with locale/direction vars.

func ReleaseCtx

func ReleaseCtx(ctx *dyntpl.Ctx)

Types

This section is empty.

Jump to

Keyboard shortcuts

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