language

package
v1.135.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 3 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.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DXLanguageEnumSetAll = []any{DXLanguageEnglish, DXLanguageIndonesian}
)
View Source
var Dictionaries = make(map[DXLanguage]map[string]string)

Dictionaries holds preloaded translations (populated by application at startup)

Functions

func LoadDictionary

func LoadDictionary(lang DXLanguage, content string)

LoadDictionary loads a dictionary from content string for a specific language

func ParseDictionary

func ParseDictionary(content string) map[string]string

ParseDictionary parses key=value format dictionary content

func Translate

func Translate(key string, lang DXLanguage, fallback DXTranslateFallbackMode) string

Translate returns the translated string for a key, with fallback behavior

Types

type DXLanguage

type DXLanguage string

DXLanguage represents supported languages for translations

const (
	DXLanguageIndonesian DXLanguage = "id"
	DXLanguageEnglish    DXLanguage = "en"
)
var DXLanguageDefault DXLanguage = DXLanguageEnglish

DXLanguageDefault is the framework default language (can be overridden by applications)

type DXTranslateFallbackMode

type DXTranslateFallbackMode string

DXTranslateFallbackMode defines how to handle missing translations

const (
	DXTranslateFallbackModeOriginal  DXTranslateFallbackMode = "original"  // Return original key
	DXTranslateFallbackModeEmpty     DXTranslateFallbackMode = "empty"     // Return empty string
	DXTranslateFallbackModeTitleCase DXTranslateFallbackMode = "titlecase" // Convert snake_case to Title Case
)

Jump to

Keyboard shortcuts

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