i18n/direction.go

Functions

Functions

func DirectionForLanguage

DirectionForLanguage returns the text direction for the given ISO 639-1

language code.

 

Returns [RTL] for Arabic, Hebrew, Persian, Urdu, and other RTL languages.

Returns [LTR] for all other languages.

func DirectionForLanguage(language string) Direction {
	if _, ok := rtlLanguages[strings.ToLower(language)]; ok {
		return RTL
	}
	return LTR
}

func IsRTL

IsRTL returns true if the direction is right-to-left.

func (d Direction) IsRTL() bool {
	return d == RTL
}

func String

String returns the human-readable name of the direction.

func (d Direction) String() string {
	switch d {
	case LTR:
		return ltrStr
	case RTL:
		return rtlStr
	default:
		return ltrStr
	}
}