Documentation ¶
Index ¶
- Constants
- Variables
- func CleanKey(s string) string
- func CreateInterpolationMapForOrganization(db types.Storage, orgID string) (orgInterpolatorMap, error)
- func ExportByGoTemplate(templateName string, project types.ExtendedProject, i18n I18N, w io.Writer) error
- func ExportExtendedProject(l logger.AppLogger, ep types.ExtendedProject, locales []string, ...) (out interface{}, contentType string, err error)
- func ExportExtendedProjectToI18Next(l logger.AppLogger, ep types.ExtendedProject, locales []string, ...) (out map[string]interface{}, err error)
- func GetMapPaths(input interface{}, paths ...string) (n [][]string, err error)
- func I18NNodeToI18Next(in I18N) (map[string]interface{}, error)
- func ImportI18NTranslation(locales types.Locales, localeHint *types.Locale, base types.Project, ...) (*Import, []Warning, error)
- func InferTitle(s string) string
- func PrepareTemplates() *template.Template
- func Prettier(s string) (string, error)
- func SplitTranslationAndContext(s, sep string) (string, string)
- type ExportI18NOptions
- type ExportOptions
- type Format
- type I18N
- type I18NWithLocales
- type Import
- type LocaleKey
- type LocaleKeyEnum
- type LocaleLookerUpper
- type Node
- type Warning
- type WarningKind
- type WarningLevel
Constants ¶
const ( WarningLevelMinor WarningLevel = "minor" WarningLevelMajor WarningLevel = "major" WarningKindTranslationVariables WarningKind = "translation-variable" WarningKindTranslationReference WarningKind = "translation-reference" )
Variables ¶
var ( LocaleKeyEnumIETF = LocaleKeyEnum{string(LocaleKeyIETF)} LocaleKeyEnumISO1 = LocaleKeyEnum{string(LocaleKeyISO1)} LocaleKeyEnumISO2 = LocaleKeyEnum{string(LocaleKeyISO2)} LocaleKeyEnumISO3 = LocaleKeyEnum{string(LocaleKeyISO3)} )
var ( FormatI18n = Format{"i18n"} FormatRaw = Format{"raw"} FormatTypescript = Format{"typescript"} )
var ( //go:embed templates Content embed.FS )
Functions ¶
func CreateInterpolationMapForOrganization ¶
func CreateInterpolationMapForOrganization(db types.Storage, orgID string) (orgInterpolatorMap, error)
Creates an prioritized interpolationmap from an organization
func ExportByGoTemplate ¶
func ExportExtendedProject ¶ added in v0.8.0
func ExportExtendedProject(l logger.AppLogger, ep types.ExtendedProject, locales []string, localeKey LocaleKeyEnum, format Format, localeFilter []string) (out interface{}, contentType string, err error)
ExportExtendedProject exports a project into a fileformat. If contentType is "", the format is a marshallable format, and can therefore be further marshalled into json, toml, yaml etc. On the other hand, some formats are not marshallable, and therefore are already ready to be returned to the user directly
for instance, typescript-format would return simply a []byte, with the contentType set to 'application/typescript'
func ExportExtendedProjectToI18Next ¶ added in v0.8.0
func ExportExtendedProjectToI18Next(l logger.AppLogger, ep types.ExtendedProject, locales []string, localeKey LocaleKeyEnum) (out map[string]interface{}, err error)
func GetMapPaths ¶
returns the map as a slice of paths where the last item in the path is the value. Fot translations, this is ok, since they are strings in any case.
func I18NNodeToI18Next ¶
func ImportI18NTranslation ¶
func ImportI18NTranslation( locales types.Locales, localeHint *types.Locale, base types.Project, source types.CreatorSource, input map[string]interface{}, ) (*Import, []Warning, error)
i18n-translations are either: a root-elemenent of type locale as key, or the category as key, or the translation as key. Every leaf-node must be of type string
func PrepareTemplates ¶
Types ¶
type ExportI18NOptions ¶
type ExportOptions ¶ added in v0.8.0
type Format ¶ added in v0.8.0
type Format struct {
// contains filtered or unexported fields
}
type I18N ¶
type I18N struct { Value string `json:"value,omitempty"` Nodes map[string]I18N `json:"nodes,omitempty"` }
func ExportI18N ¶
func ExportI18N(ex types.ExtendedProject, options ExportI18NOptions) (node I18N, err error)
func (I18N) MergeAsIfRootIsLocale ¶
func (in I18N) MergeAsIfRootIsLocale(localeGetter LocaleLookerUpper) (I18NWithLocales, error)
func (I18N) ToLocaleAwere ¶
func (in I18N) ToLocaleAwere(locale string) I18NWithLocales
type I18NWithLocales ¶
type I18NWithLocales struct { // The keys should be the ID of the locale Value map[string]string `json:"value,omitempty"` Nodes map[string]I18NWithLocales `json:"nodes,omitempty"` }
func (I18NWithLocales) Merge ¶
func (in I18NWithLocales) Merge(v I18NWithLocales) I18NWithLocales
type Import ¶
type Import struct {
Categories map[string]types.ExtendedCategory
}
The Import reprecents values that should be created in the database. The keys in each map is of no importance except for temporarily tracking these values
type LocaleKeyEnum ¶ added in v0.8.0
type LocaleKeyEnum struct {
// contains filtered or unexported fields
}
func (LocaleKeyEnum) From ¶ added in v0.8.0
func (f LocaleKeyEnum) From(s string) LocaleKeyEnum
Deprecated, only used for earlier enums
func (LocaleKeyEnum) Is ¶ added in v0.8.0
func (f LocaleKeyEnum) Is(comparitor LocaleKeyEnum) bool
func (LocaleKeyEnum) String ¶ added in v0.8.0
func (f LocaleKeyEnum) String() string
type LocaleLookerUpper ¶
Aweseome name
type Warning ¶
type Warning struct { Message string `json:"message"` Error error `json:"error,omitempty"` Details interface{} `json:"details,omitempty"` Level WarningLevel `json:"level"` Kind WarningKind `json:"kind"` }
func InferVariables ¶
type WarningKind ¶
type WarningKind string
type WarningLevel ¶
type WarningLevel string