gotext/introspector.go
Matyas Horky 3a68971094 Detect translations in high-level structs
This patch adds .IsTranslated(), .IsTranslatedN() and related functions
to following objects:
- Po
- Mo
- locale
- gotext
and it creates helper interfaces in introspector.go.

This makes it possible to detect whether a string is translatable or not
during runtime.

Resolves #42
2023-04-12 17:15:46 +02:00

25 lines
1.1 KiB
Go

package gotext
// IsTranslatedIntrospector is able to determine whether a given string is translated.
// Examples of this introspector are Po and Mo, which are specific to their domain.
// Locale holds multiple domains and also implements IsTranslatedDomainIntrospector.
type IsTranslatedIntrospector interface {
IsTranslated(str string) bool
IsTranslatedN(str string, n int) bool
IsTranslatedC(str, ctx string) bool
IsTranslatedNC(str string, n int, ctx string) bool
}
// IsTranslatedDomainIntrospector is able to determine whether a given string is translated.
// Example of this introspector is Locale, which holds multiple domains.
// Simpler objects that are domain-specific, like Po or Mo, implement IsTranslatedIntrospector.
type IsTranslatedDomainIntrospector interface {
IsTranslated(str string) bool
IsTranslatedN(str string, n int) bool
IsTranslatedD(dom, str string) bool
IsTranslatedND(dom, str string, n int) bool
IsTranslatedC(str, ctx string) bool
IsTranslatedNC(str string, n int, ctx string) bool
IsTranslatedDC(dom, str, ctx string) bool
IsTranslatedNDC(dom, str string, n int, ctx string) bool
}