Documentation
¶
Overview ¶
Package caddy_i18n provides a middleware that translates HTML responses to the user's preferred language, by using standard GNU Gettext .po files. Translatable strings are marked as such in the HTML using attributes and or tags. The middleware strips out those markers and replaces the strings with their translations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type I18n ¶
type I18n struct { // The directory where the .po files are stored. The files must be named LANGUAGE.po, where LANGUAGE is the language code (see the languages field). Translations string `json:"translations,omitempty"` // The HTML attribute used to mark inner content of the tag it is placed on as translatable strings. Defaults to i18n. HTMLAttribute string `json:"html_attribute,omitempty"` // The HTML tag used to mark inner content of the tag it is placed on as translatable strings. Defaults to i18n. HTMLTag string `json:"html_tag,omitempty"` // The language code of the content the original responses are written in. Defaults to en. SourceLanguage string `json:"source_language,omitempty"` // The target languages we should attempt to translate to. Languages []string `json:"languages,omitempty"` // Update the .po files with new translatable strings found in the HTML responses. Disabled by default. UpdateTranslations bool `json:"update_translations,omitempty"` // Include a <script>window.i18nLanguage = "...";</script> in the response to expose the language code to JavaScript. ExposeToJS bool `json:"expose_to_js,omitempty"` *zap.Logger // contains filtered or unexported fields }
func (I18n) CaddyModule ¶
func (I18n) CaddyModule() caddy.ModuleInfo
Click to show internal directories.
Click to hide internal directories.