.Go String Map Parser Plugin

Plugin source location: <serge_root>/lib/Serge/Engine/Plugin/parse_go.pm

This plugin is used to parse key-value string pairs in native Go source files.

Plugin supports extracting one- or multi-line // ... style comments that go immediately above the key-value line. Also, plugin allows to specify the string context by appending ##context at the end of the key name (see the example below).

Supported string values are regular strings (enclosed in double quotes) and raw strings (enclosed in backticks). Regular strings can have Unicode symbols escaped as \uNNNN or bytes escaped as \xNN, according to Go specification. Raw strings can span multiple lines.

Code Examples

strings.go
package main func init() { locpool.Resources["en"] = map[string]string{ // H1 Heading "WelcomeMessage##title": "Welcome!", // {NAME} is the name of the user "HelloUser": "Hello, {NAME}!", // {X} is the number of files, // {Y} is the number of folders, // {COMMAND} in the ID of the command "XFilesFoundInYFolders": `{X_PLURAL:{X} file|{X} files} found in {Y_PLURAL:{Y} folder|{Y} folders}. Do you want to {COMMAND:copy|move|delete} {X:them|it|them}?`, //... } }

Usage

example-project.serge