Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/go-i18n.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornicksnyder <nickdsnyder@gmail.com>2014-07-11 20:39:51 +0400
committernicksnyder <nickdsnyder@gmail.com>2014-07-11 20:39:51 +0400
commitccb22add9ab5ca01ae5726cfd9925a822e940986 (patch)
treefcd5422a1d605643530c8e0997c717030e20fcb9
parent75b545184f0f6ead650077a2a8e9b3e8c9f7180f (diff)
Create gh-pages branch via GitHub
-rw-r--r--index.html144
-rw-r--r--params.json2
2 files changed, 32 insertions, 114 deletions
diff --git a/index.html b/index.html
index 067c304..849c7c7 100644
--- a/index.html
+++ b/index.html
@@ -35,112 +35,23 @@
<a name="go-i18n-" class="anchor" href="#go-i18n-"><span class="octicon octicon-link"></span></a>go-i18n <a href="http://travis-ci.org/nicksnyder/go-i18n"><img src="https://secure.travis-ci.org/nicksnyder/go-i18n.png?branch=master" alt="Build Status"></a>
</h1>
-<p>go-i18n is a Go <a href="#i18n-package">package</a> and a <a href="#goi18n-command">command</a> that can be used to translate Go programs into multiple lanaguages.</p>
-
-<p>Requires Go 1.2.</p>
-
-<h2>
-<a name="features" class="anchor" href="#features"><span class="octicon octicon-link"></span></a>Features</h2>
+<p>go-i18n is a Go <a href="#i18n-package">package</a> and a <a href="#goi18n-command">command</a> that can be used to translate Go programs into multiple languages.</p>
<ul>
-<li>Implements <a href="http://cldr.unicode.org/index/cldr-spec/plural-rules">CLDR plural rules</a>.</li>
-<li>Uses <a href="http://golang.org/pkg/text/template/">text/template</a> for strings with variables.</li>
+<li>Supports pluralized strings using <a href="http://cldr.unicode.org/index/cldr-spec/plural-rules">CLDR plural rules</a>.</li>
+<li>Supports strings with named variables using <a href="http://golang.org/pkg/text/template/">text/template</a> syntax.</li>
<li>Translation files are simple JSON.</li>
<li>
<a href="http://godoc.org/github.com/nicksnyder/go-i18n">Documented</a> and <a href="https://travis-ci.org/nicksnyder/go-i18n">tested</a>!</li>
</ul><h2>
-<a name="i18n-package" class="anchor" href="#i18n-package"><span class="octicon octicon-link"></span></a>i18n package</h2>
-
-<p>The i18n package provides runtime APIs for looking up translated strings.</p>
-
-<div class="highlight highlight-go"><pre><span class="kn">import</span> <span class="s">"github.com/nicksnyder/go-i18n/i18n"</span>
-</pre></div>
-
-<h5>
-<a name="loading-translations" class="anchor" href="#loading-translations"><span class="octicon octicon-link"></span></a>Loading translations</h5>
-
-<p>Load translation files during your program's initialization.
-The name of a translation file must contain a supported <a href="http://en.wikipedia.org/wiki/IETF_language_tag">language tag</a>.</p>
-
-<div class="highlight highlight-go"><pre><span class="nx">i18n</span><span class="p">.</span><span class="nx">MustLoadTranslationFile</span><span class="p">(</span><span class="s">"path/to/fr-FR.all.json"</span><span class="p">)</span>
-</pre></div>
-
-<h5>
-<a name="selecting-a-locale" class="anchor" href="#selecting-a-locale"><span class="octicon octicon-link"></span></a>Selecting a locale</h5>
-
-<p>Tfunc returns a function that can lookup the translation of a string for that locale.
-It accepts multiple locale parameters so you can gracefully fallback to other locales.</p>
-
-<div class="highlight highlight-go"><pre><span class="nx">userLocale</span> <span class="p">=</span> <span class="s">"ar-AR"</span> <span class="c1">// user preference, accept header, language cookie</span>
-<span class="nx">defaultLocale</span> <span class="p">=</span> <span class="s">"en-US"</span> <span class="c1">// known valid locale</span>
-<span class="nx">T</span><span class="p">,</span> <span class="nx">err</span> <span class="o">:=</span> <span class="nx">i18n</span><span class="p">.</span><span class="nx">Tfunc</span><span class="p">(</span><span class="nx">userLocale</span><span class="p">,</span> <span class="nx">defaultLocale</span><span class="p">)</span>
-</pre></div>
-
-<h5>
-<a name="loading-a-string-translation" class="anchor" href="#loading-a-string-translation"><span class="octicon octicon-link"></span></a>Loading a string translation</h5>
-
-<p>Use the translation function to fetch the translation of a string.</p>
-
-<div class="highlight highlight-go"><pre><span class="nx">fmt</span><span class="p">.</span><span class="nx">Println</span><span class="p">(</span><span class="nx">T</span><span class="p">(</span><span class="s">"Hello world"</span><span class="p">))</span>
-</pre></div>
-
-<p>Usually it is a good idea to identify strings by a generic id rather than the English translation, but the rest of this document will continue to use the English translation for readability.</p>
-
-<div class="highlight highlight-go"><pre><span class="nx">T</span><span class="p">(</span><span class="s">"program_greeting"</span><span class="p">)</span>
-</pre></div>
+<a name="package-i18n-" class="anchor" href="#package-i18n-"><span class="octicon octicon-link"></span></a>Package i18n <a href="http://godoc.org/github.com/nicksnyder/go-i18n/i18n"><img src="http://godoc.org/github.com/nicksnyder/go-i18n?status.png" alt="GoDoc"></a>
+</h2>
-<h5>
-<a name="strings-with-variables" class="anchor" href="#strings-with-variables"><span class="octicon octicon-link"></span></a>Strings with variables</h5>
-
-<p>You can have variables in your string using <a href="http://golang.org/pkg/text/template/">text/template</a> syntax.</p>
-
-<div class="highlight highlight-go"><pre><span class="nx">T</span><span class="p">(</span><span class="s">"Hello {{.Person}}"</span><span class="p">,</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span>
- <span class="s">"Person"</span><span class="p">:</span> <span class="s">"Bob"</span><span class="p">,</span>
-<span class="p">})</span>
-</pre></div>
-
-<h5>
-<a name="plural-strings" class="anchor" href="#plural-strings"><span class="octicon octicon-link"></span></a>Plural strings</h5>
-
-<p>Each language handles pluralization differently. A few examples:</p>
-
-<ul>
-<li>English treats one as singular and all other numbers as plural (e.g. 0 cats, 1 cat, 2 cats).</li>
-<li>French treats zero as singular.</li>
-<li>Japan has a single plural form for all numbers.</li>
-<li>Arabic has six different plural forms!</li>
-</ul><p>The translation function handles <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html">all of this logic</a> for you.</p>
-
-<div class="highlight highlight-go"><pre><span class="nx">T</span><span class="p">(</span><span class="s">"You have {{.Count}} unread emails"</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
-<span class="nx">T</span><span class="p">(</span><span class="s">"I am {{.Count}} meters tall."</span><span class="p">,</span> <span class="s">"1.7"</span><span class="p">)</span>
-</pre></div>
-
-<p>With variables:</p>
-
-<div class="highlight highlight-go"><pre><span class="nx">T</span><span class="p">(</span><span class="s">"{{.Person}} has {{.Count}} unread emails"</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span>
- <span class="s">"Person"</span><span class="p">:</span> <span class="s">"Bob"</span><span class="p">,</span>
-<span class="p">})</span>
-</pre></div>
-
-<p>Sentences with multiple plural components can be supported with nesting.</p>
-
-<div class="highlight highlight-go"><pre><span class="nx">T</span><span class="p">(</span><span class="s">"{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}."</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="kd">interface</span><span class="p">{}{</span>
- <span class="s">"Person"</span><span class="p">:</span> <span class="s">"Bob"</span><span class="p">,</span>
- <span class="s">"Timeframe"</span><span class="p">:</span> <span class="nx">T</span><span class="p">(</span><span class="s">"{{.Count}} days"</span><span class="p">,</span> <span class="mi">2</span><span class="p">),</span>
-<span class="p">})</span>
-</pre></div>
-
-<p>A complete example is <a href="https://github.com/nicksnyder/go-i18n/blob/master/i18n/example_test.go">here</a>.</p>
-
-<h5>
-<a name="strings-in-templates" class="anchor" href="#strings-in-templates"><span class="octicon octicon-link"></span></a>Strings in templates</h5>
-
-<p>You can call the <code>.Funcs()</code> method on a <a href="http://golang.org/pkg/text/template/#Template.Funcs">text/template</a> or <a href="http://golang.org/pkg/html/template/#Template.Funcs">html/template</a> to register the translation function for usage inside of that template.</p>
-
-<p>A complete example is <a href="https://github.com/nicksnyder/go-i18n/blob/master/i18n/exampletemplate_test.go">here</a>.</p>
+<p>The i18n package provides runtime APIs for fetching translated strings.</p>
<h2>
-<a name="goi18n-command" class="anchor" href="#goi18n-command"><span class="octicon octicon-link"></span></a>goi18n command</h2>
+<a name="command-goi18n-" class="anchor" href="#command-goi18n-"><span class="octicon octicon-link"></span></a>Command goi18n <a href="http://godoc.org/github.com/nicksnyder/go-i18n/goi18n"><img src="http://godoc.org/github.com/nicksnyder/go-i18n?status.png" alt="GoDoc"></a>
+</h2>
<p>The goi18n command provides functionality for managing the translation process.</p>
@@ -248,6 +159,7 @@ goi18n -help
<ul>
<li>Arabic (<code>ar</code>)</li>
+<li>Bulgarian (<code>bg</code>)</li>
<li>Catalan (<code>ca</code>)</li>
<li>Chinese (simplified and traditional) (<code>zh</code>)</li>
<li>Czech (<code>cs</code>)</li>
@@ -256,41 +168,47 @@ goi18n -help
<li>English (<code>en</code>)</li>
<li>French (<code>fr</code>)</li>
<li>German (<code>de</code>)</li>
+<li>Icelandic (<code>is</code>)</li>
<li>Italian (<code>it</code>)</li>
<li>Japanese (<code>ja</code>)</li>
+<li>Lithuanian (<code>lt</code>)</li>
<li>Portuguese (<code>pt</code>)</li>
<li>Portuguese (Brazilian) (<code>pt-BR</code>)</li>
<li>Spanish (<code>es</code>)</li>
-</ul><p>More languages are straightforward to add:</p>
+<li>Swedish (<code>sv</code>)</li>
+</ul><h2>
+<a name="adding-new-languages" class="anchor" href="#adding-new-languages"><span class="octicon octicon-link"></span></a>Adding new languages</h2>
+
+<p>It is easy to add support for additional languages:</p>
<ol>
<li>Lookup the language's <a href="http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html">CLDR plural rules</a>.</li>
<li>
-<p>Add the language to <a href="https://github.com/nicksnyder/go-i18n/blob/master/i18n/language/language.go">language.go</a>:</p>
+<p>Add the language to <a href="https://github.com/nicksnyder/go-i18n/blob/master/i18n/language/pluralspec.go">pluralspec.go</a>:</p>
-<div class="highlight highlight-go"><pre><span class="kd">var</span> <span class="nx">languages</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="o">*</span><span class="nx">Language</span><span class="p">{</span>
+<div class="highlight highlight-go"><pre><span class="kd">var</span> <span class="nx">pluralSpecs</span> <span class="p">=</span> <span class="kd">map</span><span class="p">[</span><span class="kt">string</span><span class="p">]</span><span class="o">*</span><span class="nx">PluralSpec</span><span class="p">{</span>
<span class="c1">// ...</span>
- <span class="s">"en"</span><span class="p">:</span> <span class="o">&amp;</span><span class="nx">Language</span><span class="p">{</span>
- <span class="nx">ID</span><span class="p">:</span> <span class="s">"en"</span><span class="p">,</span>
- <span class="nx">Name</span><span class="p">:</span> <span class="s">"English"</span><span class="p">,</span>
- <span class="nx">PluralCategories</span><span class="p">:</span> <span class="nx">newSet</span><span class="p">(</span><span class="nx">plural</span><span class="p">.</span><span class="nx">One</span><span class="p">,</span> <span class="nx">plural</span><span class="p">.</span><span class="nx">Other</span><span class="p">),</span>
- <span class="nx">PluralFunc</span><span class="p">:</span> <span class="kd">func</span><span class="p">(</span><span class="nx">ops</span> <span class="o">*</span><span class="nx">plural</span><span class="p">.</span><span class="nx">Operands</span><span class="p">)</span> <span class="nx">plural</span><span class="p">.</span><span class="nx">Category</span> <span class="p">{</span>
- <span class="k">if</span> <span class="nx">ops</span><span class="p">.</span><span class="nx">I</span> <span class="o">==</span> <span class="mi">1</span> <span class="o">&amp;&amp;</span> <span class="nx">ops</span><span class="p">.</span><span class="nx">V</span> <span class="o">==</span> <span class="mi">0</span> <span class="p">{</span>
- <span class="k">return</span> <span class="nx">plural</span><span class="p">.</span><span class="nx">One</span>
- <span class="p">}</span>
- <span class="k">return</span> <span class="nx">plural</span><span class="p">.</span><span class="nx">Other</span>
- <span class="p">},</span>
- <span class="p">},</span>
+ <span class="c1">// English</span>
+ <span class="s">"en"</span><span class="p">:</span> <span class="o">&amp;</span><span class="nx">PluralSpec</span><span class="p">{</span>
+ <span class="nx">Plurals</span><span class="p">:</span> <span class="nx">newPluralSet</span><span class="p">(</span><span class="nx">One</span><span class="p">,</span> <span class="nx">Other</span><span class="p">),</span>
+ <span class="nx">PluralFunc</span><span class="p">:</span> <span class="kd">func</span><span class="p">(</span><span class="nx">ops</span> <span class="o">*</span><span class="nx">operands</span><span class="p">)</span> <span class="nx">Plural</span> <span class="p">{</span>
+ <span class="k">if</span> <span class="nx">ops</span><span class="p">.</span><span class="nx">I</span> <span class="o">==</span> <span class="mi">1</span> <span class="o">&amp;&amp;</span> <span class="nx">ops</span><span class="p">.</span><span class="nx">V</span> <span class="o">==</span> <span class="mi">0</span> <span class="p">{</span>
+ <span class="k">return</span> <span class="nx">One</span>
+ <span class="p">}</span>
+ <span class="k">return</span> <span class="nx">Other</span>
+ <span class="p">},</span>
+ <span class="p">},</span>
<span class="c1">// ...</span>
<span class="p">}</span>
</pre></div>
</li>
-<li><p>Add a test to <a href="https://github.com/nicksnyder/go-i18n/blob/master/i18n/language/language_test.go">language_test.go</a></p></li>
+<li><p>Add a test to <a href="https://github.com/nicksnyder/go-i18n/blob/master/i18n/language/pluralspec_test.go">pluralspec_test.go</a></p></li>
+<li>Update this README with the new language.</li>
<li>Submit a pull request!</li>
</ol><h2>
<a name="license" class="anchor" href="#license"><span class="octicon octicon-link"></span></a>License</h2>
-<p>go-i18n is available under the MIT license. See the <a href="LICENSE">LICENSE</a> file for more info.</p>
+<p>go-i18n is available under the MIT license. See the <a href="https://github.com/nicksnyder/go-i18n/blob/master/LICENSE">LICENSE</a> file for more info.</p>
</section>
</div>
diff --git a/params.json b/params.json
index 068e548..e807096 100644
--- a/params.json
+++ b/params.json
@@ -1 +1 @@
-{"name":"go-i18n","tagline":"Translate your Go program into multiple languages with templates and CLDR plural support.","body":"go-i18n [![Build Status](https://secure.travis-ci.org/nicksnyder/go-i18n.png?branch=master)](http://travis-ci.org/nicksnyder/go-i18n)\r\n=======\r\n\r\ngo-i18n is a Go [package](#i18n-package) and a [command](#goi18n-command) that can be used to translate Go programs into multiple lanaguages.\r\n\r\nRequires Go 1.2.\r\n\r\nFeatures\r\n--------\r\n\r\n* Implements [CLDR plural rules](http://cldr.unicode.org/index/cldr-spec/plural-rules).\r\n* Uses [text/template](http://golang.org/pkg/text/template/) for strings with variables.\r\n* Translation files are simple JSON.\r\n* [Documented](http://godoc.org/github.com/nicksnyder/go-i18n) and [tested](https://travis-ci.org/nicksnyder/go-i18n)!\r\n\r\ni18n package\r\n------------\r\n\r\nThe i18n package provides runtime APIs for looking up translated strings.\r\n\r\n```go\r\nimport \"github.com/nicksnyder/go-i18n/i18n\"\r\n```\r\n\r\n##### Loading translations\r\n\r\nLoad translation files during your program's initialization.\r\nThe name of a translation file must contain a supported [language tag](http://en.wikipedia.org/wiki/IETF_language_tag).\r\n\r\n```go\r\ni18n.MustLoadTranslationFile(\"path/to/fr-FR.all.json\")\r\n```\r\n\r\n##### Selecting a locale\r\n\r\nTfunc returns a function that can lookup the translation of a string for that locale.\r\nIt accepts multiple locale parameters so you can gracefully fallback to other locales.\r\n\r\n```go\r\nuserLocale = \"ar-AR\" // user preference, accept header, language cookie\r\ndefaultLocale = \"en-US\" // known valid locale\r\nT, err := i18n.Tfunc(userLocale, defaultLocale)\r\n```\r\n\r\n##### Loading a string translation\r\n\r\nUse the translation function to fetch the translation of a string.\r\n\r\n```go\r\nfmt.Println(T(\"Hello world\"))\r\n```\r\n\r\nUsually it is a good idea to identify strings by a generic id rather than the English translation, but the rest of this document will continue to use the English translation for readability.\r\n\r\n```go\r\nT(\"program_greeting\")\r\n```\r\n\r\n##### Strings with variables\r\n\r\nYou can have variables in your string using [text/template](http://golang.org/pkg/text/template/) syntax.\r\n\r\n```go\r\nT(\"Hello {{.Person}}\", map[string]interface{}{\r\n\t\"Person\": \"Bob\",\r\n})\r\n```\r\n\r\n##### Plural strings\r\n\r\nEach language handles pluralization differently. A few examples:\r\n* English treats one as singular and all other numbers as plural (e.g. 0 cats, 1 cat, 2 cats).\r\n* French treats zero as singular.\r\n* Japan has a single plural form for all numbers.\r\n* Arabic has six different plural forms!\r\n\r\nThe translation function handles [all of this logic](http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html) for you.\r\n\r\n```go\r\nT(\"You have {{.Count}} unread emails\", 2)\r\nT(\"I am {{.Count}} meters tall.\", \"1.7\")\r\n```\r\n\r\nWith variables:\r\n\r\n```go\r\nT(\"{{.Person}} has {{.Count}} unread emails\", 2, map[string]interface{}{\r\n\t\"Person\": \"Bob\",\r\n})\r\n```\r\n\r\nSentences with multiple plural components can be supported with nesting.\r\n\r\n```go\r\nT(\"{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}.\", 3, map[string]interface{}{\r\n\t\"Person\": \"Bob\",\r\n\t\"Timeframe\": T(\"{{.Count}} days\", 2),\r\n})\r\n```\r\n\r\nA complete example is [here](https://github.com/nicksnyder/go-i18n/blob/master/i18n/example_test.go).\r\n\r\n##### Strings in templates\r\n\r\nYou can call the `.Funcs()` method on a [text/template](http://golang.org/pkg/text/template/#Template.Funcs) or [html/template](http://golang.org/pkg/html/template/#Template.Funcs) to register the translation function for usage inside of that template.\r\n\r\nA complete example is [here](https://github.com/nicksnyder/go-i18n/blob/master/i18n/exampletemplate_test.go).\r\n\r\ngoi18n command\r\n--------------\r\n\r\nThe goi18n command provides functionality for managing the translation process.\r\n\r\n### Installation\r\n\r\nMake sure you have [setup GOPATH](http://golang.org/doc/code.html#GOPATH).\r\n\r\n go get -u github.com/nicksnyder/go-i18n/goi18n\r\n goi18n -help\r\n\r\n### Workflow\r\n\r\nA typical workflow looks like this:\r\n\r\n1. Add a new string to your source code.\r\n\r\n ```go\r\n T(\"settings_title\")\r\n ```\r\n\r\n2. Add the string to en-US.all.json\r\n\r\n ```json\r\n [\r\n {\r\n \"id\": \"settings_title\",\r\n \"translation\": \"Settings\"\r\n }\r\n ]\r\n ```\r\n\r\n3. Run goi18n\r\n\r\n ```\r\n goi18n path/to/*.all.json\r\n ```\r\n\r\n4. Send `path/to/*.untranslated.json` to get translated.\r\n5. Run goi18n again to merge the translations\r\n\r\n ```sh\r\n goi18n path/to/*.all.json path/to/*.untranslated.json\r\n ```\r\n\r\nTranslation files\r\n-----------------\r\n\r\nA translation file stores translated and untranslated strings.\r\n\r\nExample:\r\n\r\n```json\r\n[\r\n {\r\n \"id\": \"d_days\",\r\n \"translation\": {\r\n \"one\": \"{{.Count}} day\",\r\n \"other\": \"{{.Count}} days\"\r\n }\r\n },\r\n {\r\n \"id\": \"my_height_in_meters\",\r\n \"translation\": {\r\n \"one\": \"I am {{.Count}} meter tall.\",\r\n \"other\": \"I am {{.Count}} meters tall.\"\r\n }\r\n },\r\n {\r\n \"id\": \"person_greeting\",\r\n \"translation\": \"Hello {{.Person}}\"\r\n },\r\n {\r\n \"id\": \"person_unread_email_count\",\r\n \"translation\": {\r\n \"one\": \"{{.Person}} has {{.Count}} unread email.\",\r\n \"other\": \"{{.Person}} has {{.Count}} unread emails.\"\r\n }\r\n },\r\n {\r\n \"id\": \"person_unread_email_count_timeframe\",\r\n \"translation\": {\r\n \"one\": \"{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}.\",\r\n \"other\": \"{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}.\"\r\n }\r\n },\r\n {\r\n \"id\": \"program_greeting\",\r\n \"translation\": \"Hello world\"\r\n },\r\n {\r\n \"id\": \"your_unread_email_count\",\r\n \"translation\": {\r\n \"one\": \"You have {{.Count}} unread email.\",\r\n \"other\": \"You have {{.Count}} unread emails.\"\r\n }\r\n }\r\n]\r\n```\r\n\r\nSupported languages\r\n-------------------\r\n\r\n* Arabic (`ar`)\r\n* Catalan (`ca`)\r\n* Chinese (Simplified) (`zh-Hans`)\r\n* Chinese (Traditional) (`zh-Hant`)\r\n* Czech (`cs`)\r\n* Danish (`da`)\r\n* Dutch (`nl`)\r\n* English (`en`)\r\n* French (`fr`)\r\n* German (`de`)\r\n* Italian (`it`)\r\n* Japanese (`ja`)\r\n* Portuguese (`pt`)\r\n* Portuguese (Brazilian) (`pt-BR`)\r\n* Spanish (`es`)\r\n\r\nMore languages are straightforward to add:\r\n\r\n1. Lookup the language's [CLDR plural rules](http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html).\r\n2. Add the language to [language.go](https://github.com/nicksnyder/go-i18n/blob/master/i18n/language/language.go):\r\n\r\n ```go\r\n var languages = map[string]*Language{\r\n // ...\r\n \"en\": &Language{\r\n ID: \"en\",\r\n Name: \"English\",\r\n PluralCategories: newSet(plural.One, plural.Other),\r\n PluralFunc: func(ops *plural.Operands) plural.Category {\r\n if ops.I == 1 && ops.V == 0 {\r\n return plural.One\r\n }\r\n return plural.Other\r\n },\r\n },\r\n // ...\r\n }\r\n ```\r\n\r\n3. Add a test to [language_test.go](https://github.com/nicksnyder/go-i18n/blob/master/i18n/language/language_test.go)\r\n4. Submit a pull request!\r\n\r\nLicense\r\n-------\r\ngo-i18n is available under the MIT license. See the [LICENSE](LICENSE) file for more info.","google":"UA-47572933-1","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file
+{"name":"go-i18n","tagline":"Translate your Go program into multiple languages with templates and CLDR plural support.","body":"go-i18n [![Build Status](https://secure.travis-ci.org/nicksnyder/go-i18n.png?branch=master)](http://travis-ci.org/nicksnyder/go-i18n)\r\n=======\r\n\r\ngo-i18n is a Go [package](#i18n-package) and a [command](#goi18n-command) that can be used to translate Go programs into multiple languages.\r\n* Supports pluralized strings using [CLDR plural rules](http://cldr.unicode.org/index/cldr-spec/plural-rules).\r\n* Supports strings with named variables using [text/template](http://golang.org/pkg/text/template/) syntax.\r\n* Translation files are simple JSON.\r\n* [Documented](http://godoc.org/github.com/nicksnyder/go-i18n) and [tested](https://travis-ci.org/nicksnyder/go-i18n)!\r\n\r\nPackage i18n [![GoDoc](http://godoc.org/github.com/nicksnyder/go-i18n?status.png)](http://godoc.org/github.com/nicksnyder/go-i18n/i18n)\r\n------------\r\n\r\nThe i18n package provides runtime APIs for fetching translated strings.\r\n\r\nCommand goi18n [![GoDoc](http://godoc.org/github.com/nicksnyder/go-i18n?status.png)](http://godoc.org/github.com/nicksnyder/go-i18n/goi18n)\r\n--------------\r\n\r\nThe goi18n command provides functionality for managing the translation process.\r\n\r\n### Installation\r\n\r\nMake sure you have [setup GOPATH](http://golang.org/doc/code.html#GOPATH).\r\n\r\n go get -u github.com/nicksnyder/go-i18n/goi18n\r\n goi18n -help\r\n\r\n### Workflow\r\n\r\nA typical workflow looks like this:\r\n\r\n1. Add a new string to your source code.\r\n\r\n ```go\r\n T(\"settings_title\")\r\n ```\r\n\r\n2. Add the string to en-US.all.json\r\n\r\n ```json\r\n [\r\n {\r\n \"id\": \"settings_title\",\r\n \"translation\": \"Settings\"\r\n }\r\n ]\r\n ```\r\n\r\n3. Run goi18n\r\n\r\n ```\r\n goi18n path/to/*.all.json\r\n ```\r\n\r\n4. Send `path/to/*.untranslated.json` to get translated.\r\n5. Run goi18n again to merge the translations\r\n\r\n ```sh\r\n goi18n path/to/*.all.json path/to/*.untranslated.json\r\n ```\r\n\r\nTranslation files\r\n-----------------\r\n\r\nA translation file stores translated and untranslated strings.\r\n\r\nExample:\r\n\r\n```json\r\n[\r\n {\r\n \"id\": \"d_days\",\r\n \"translation\": {\r\n \"one\": \"{{.Count}} day\",\r\n \"other\": \"{{.Count}} days\"\r\n }\r\n },\r\n {\r\n \"id\": \"my_height_in_meters\",\r\n \"translation\": {\r\n \"one\": \"I am {{.Count}} meter tall.\",\r\n \"other\": \"I am {{.Count}} meters tall.\"\r\n }\r\n },\r\n {\r\n \"id\": \"person_greeting\",\r\n \"translation\": \"Hello {{.Person}}\"\r\n },\r\n {\r\n \"id\": \"person_unread_email_count\",\r\n \"translation\": {\r\n \"one\": \"{{.Person}} has {{.Count}} unread email.\",\r\n \"other\": \"{{.Person}} has {{.Count}} unread emails.\"\r\n }\r\n },\r\n {\r\n \"id\": \"person_unread_email_count_timeframe\",\r\n \"translation\": {\r\n \"one\": \"{{.Person}} has {{.Count}} unread email in the past {{.Timeframe}}.\",\r\n \"other\": \"{{.Person}} has {{.Count}} unread emails in the past {{.Timeframe}}.\"\r\n }\r\n },\r\n {\r\n \"id\": \"program_greeting\",\r\n \"translation\": \"Hello world\"\r\n },\r\n {\r\n \"id\": \"your_unread_email_count\",\r\n \"translation\": {\r\n \"one\": \"You have {{.Count}} unread email.\",\r\n \"other\": \"You have {{.Count}} unread emails.\"\r\n }\r\n }\r\n]\r\n```\r\n\r\nSupported languages\r\n-------------------\r\n\r\n* Arabic (`ar`)\r\n* Bulgarian (`bg`)\r\n* Catalan (`ca`)\r\n* Chinese (simplified and traditional) (`zh`)\r\n* Czech (`cs`)\r\n* Danish (`da`)\r\n* Dutch (`nl`)\r\n* English (`en`)\r\n* French (`fr`)\r\n* German (`de`)\r\n* Icelandic (`is`)\r\n* Italian (`it`)\r\n* Japanese (`ja`)\r\n* Lithuanian (`lt`)\r\n* Portuguese (`pt`)\r\n* Portuguese (Brazilian) (`pt-BR`)\r\n* Spanish (`es`)\r\n* Swedish (`sv`)\r\n\r\nAdding new languages\r\n--------------------\r\n\r\nIt is easy to add support for additional languages:\r\n\r\n1. Lookup the language's [CLDR plural rules](http://www.unicode.org/cldr/charts/latest/supplemental/language_plural_rules.html).\r\n2. Add the language to [pluralspec.go](https://github.com/nicksnyder/go-i18n/blob/master/i18n/language/pluralspec.go):\r\n\r\n ```go\r\n var pluralSpecs = map[string]*PluralSpec{\r\n // ...\r\n\t\t\t\t// English\r\n\t\t\t\t\"en\": &PluralSpec{\r\n\t\t\t\t\tPlurals: newPluralSet(One, Other),\r\n\t\t\t\t\tPluralFunc: func(ops *operands) Plural {\r\n\t\t\t\t\t\tif ops.I == 1 && ops.V == 0 {\r\n\t\t\t\t\t\t\treturn One\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\treturn Other\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n // ...\r\n }\r\n ```\r\n\r\n3. Add a test to [pluralspec_test.go](https://github.com/nicksnyder/go-i18n/blob/master/i18n/language/pluralspec_test.go)\r\n4. Update this README with the new language.\r\n5. Submit a pull request!\r\n\r\nLicense\r\n-------\r\ngo-i18n is available under the MIT license. See the [LICENSE](https://github.com/nicksnyder/go-i18n/blob/master/LICENSE) file for more info.\r\n","google":"UA-47572933-1","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file