.\" Hey, EMACS: -*- nroff -*- .\" (C) Copyright 2020 Anthony Fok , .\" .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) .TH GOI18N "1" "2020-10-29" "goi18n (v2)" "goi18n Manual" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: .\" .nh disable hyphenation .\" .hy enable hyphenation .\" .ad l left justify .\" .ad b justify to both left and right margins .\" .nf disable filling .\" .fi enable filling .\" .br insert line break .\" .sp insert n+1 empty lines .\" for manpage-specific macros, see man(7) .nh .ad l .SH NAME goi18n \- a tool for managing message translations .SH SYNOPSIS .B goi18n .I command .RI [ arguments ] .SH DESCRIPTION .\" TeX users may be more comfortable with the \fB\fP and .\" \fI\fP escape sequences to invode bold face and italics, .\" respectively. The \fBgoi18n\fP command manages message files used by the i18n (github.com/nicksnyder/go-i18n/v2/i18n) Go package. .SH WORKFLOW \& .SS Extracting messages \& .TP 4 Use \(lq\fBgoi18n extract\fP\(rq to extract all i18n.Message struct literals in Go source files to a message file for translation. \& .EX # active.en.toml [PersonCats] description = "The number of cats a person has" one = "{{.Name}} has {{.Count}} cat." other = "{{.Name}} has {{.Count}} cats." .EE .nh \& .SS Translating a new language \& .IP "1." 3 Create an empty message file for the language that you want to add (e.g. \fItranslate.es.toml\fP). .IP "2." 3 Run \(lq\fBgoi18n merge active.en.toml translate.es.toml\fP\(rq to populate \fItranslate.es.toml\fP with the mesages to be translated. .IP "" 4 .EX # translate.es.toml [PersonCats] description = "The number of cats a person has" hash = "sha1-f937a0e05e19bfe6cd70937c980eaf1f9832f091" one = "{{.Name}} has {{.Count}} cat." other = "{{.Name}} has {{.Count}} cats." .EE .nh \& .IP "3." 3 After \fItranslate.es.toml\fP has been translated, rename it to \fIactive.es.toml\fP. \& .IP "" 4 .EX # active.es.toml [PersonCats] description = "The number of cats a person has" hash = "sha1-f937a0e05e19bfe6cd70937c980eaf1f9832f091" one = "{{.Name}} tiene {{.Count}} gato." other = "{{.Name}} tiene {{.Count}} gatos." .EE .nh \& .TP .IP "4." 3 Load \fIactive.es.toml\fP into your bundle. \& .IP "" 4 .EX bundle.RegisterUnmarshalFunc("toml", toml.Unmarshal) bundle.MustLoadMessageFile("active.es.toml") .EE .nh \& .SS Translating new messages \& .PP If you have added new messages to your program: .IP " 1." 4 Run \(lq\fBgoi18n extract\fP\(rq to update \fIactive.en.toml\fP with the new messages. .IP " 2." 4 Run \(lq\fBgoi18n merge active.*.toml\fP\(rq to generate updated \fItranslate.*.toml\fP files. .IP " 3." 4 Translate all the messages in the \fItranslate.*.toml\fP files. .IP " 4." 4 Run \(lq\fBgoi18n merge active.*.toml translate.*.toml\fP\(rq to merge the translated messages into the active message files. .SH AUTHOR goi18n is written by Nick Snyder. .PP This manual page is prepared for Debian by Anthony Fok using information from upstream README.md and output of \fBgoi18n \-help\fP. .SH COPYRIGHT Copyright \(co 2012\(en2020 Nick Snyder .br License: MIT (Expat) .SH SEE ALSO Full documentation at \m[blue]\fBhttps://github.com/nicksnyder/go-i18n\fR\m[]