Archived
1
0

update i18n stuff

This commit is contained in:
Jeff Becker 2017-10-10 12:34:39 -04:00
parent e25b84c686
commit 0848412aa0
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
7 changed files with 22 additions and 18 deletions

View File

@ -18,7 +18,7 @@ type I18N struct {
// root directory for translations // root directory for translations
translation_dir string translation_dir string
// name of locale // name of locale
name string Name string
} }
var I18nProvider *I18N = nil var I18nProvider *I18N = nil
@ -71,7 +71,7 @@ func NewI18n(locale, dir string) (*I18N, error) {
} }
return &I18N{ return &I18N{
name: locale, Name: locale,
translation_dir: dir, translation_dir: dir,
Formats: formats.Options(), Formats: formats.Options(),
Translations: translations.Options(), Translations: translations.Options(),

View File

@ -486,7 +486,11 @@ func (self *post) Attachments() []AttachmentModel {
} }
func (self *post) PostURL() string { func (self *post) PostURL() string {
return fmt.Sprintf("%st/%s/#%s", self.Prefix(), HashMessageID(self.Parent), self.PostHash()) i18n := self._i18n
if i18n == nil {
i18n = I18nProvider
}
return fmt.Sprintf("%st/%s/?lang=%s#%s", self.Prefix(), HashMessageID(self.Parent), i18n.Name, self.PostHash())
} }
func (self *post) Prefix() string { func (self *post) Prefix() string {

View File

@ -29,7 +29,7 @@ type nullHandler struct {
func (self *nullHandler) GetI18N(r *http.Request) *I18N { func (self *nullHandler) GetI18N(r *http.Request) *I18N {
lang := r.URL.Query().Get("lang") lang := r.URL.Query().Get("lang")
if lang == "" { if lang == "" {
lang = I18nProvider.name lang = I18nProvider.Name
} }
self.access.Lock() self.access.Lock()
i, ok := self.i18n[lang] i, ok := self.i18n[lang]

View File

@ -24,7 +24,7 @@
<meta property="og:site_name" content="changolia" /> <meta property="og:site_name" content="changolia" />
<meta property="og:type" content="website"/> <meta property="og:type" content="website"/>
<meta property="og:title" content="{{board.Board}}"/> <meta property="og:title" content="{{board.Board}}"/>
<meta property="og:url" content="{{board.Prefix}}b/{{board.Board}}/"/> <meta property="og:url" content="{{board.Prefix}}b/{{board.Board}}/?lang={{i18n.Name}}"/>
<meta property="og:description" content="{{board.Board}} on changolia"/> <meta property="og:description" content="{{board.Board}} on changolia"/>
<meta property="og:image" <meta property="og:image"

View File

@ -13,15 +13,15 @@
<input type="hidden" name="reference" value="{{reference}}" id="postform_reference"/> <input type="hidden" name="reference" value="{{reference}}" id="postform_reference"/>
<table cellspacing="1" cellpadding="0"> <table cellspacing="1" cellpadding="0">
<tr> <tr>
<th>Name</th> <th>{{#i18n.Translations}}{{name}}{{/i18n.Translations}}</th>
<td><input type="text" name="name" class="posttext" /></td> <td><input type="text" name="name" class="posttext" /></td>
</tr> </tr>
<tr> <tr>
<th>Subject</th> <th>{{#i18n.Translations}}{{subject}}{{/i18n.Translations}}</th>
<td><input type="text" name="subject" class="posttext" /></td> <td><input type="text" name="subject" class="posttext" /></td>
</tr> </tr>
<tr> <tr>
<th>Comment</th> <th>{{#i18n.Translations}}{{comment}}{{/i18n.Translations}}</th>
<td><textarea id="comment" name="message" class="postarea"></textarea></td> <td><textarea id="comment" name="message" class="postarea"></textarea></td>
</tr> </tr>
{{^DisableCaptcha}} {{^DisableCaptcha}}
@ -45,7 +45,7 @@
{{/DisableCaptcha}} {{/DisableCaptcha}}
{{#files}} {{#files}}
<tr> <tr>
<th>File</th> <th>{{#i18n.Translations}}{{file}}{{/i18n.Translations}}</th>
<td> <td>
<table cellspacing="0" cellpadding="0" width="100%"> <table cellspacing="0" cellpadding="0" width="100%">
<tr> <tr>

View File

@ -24,7 +24,7 @@
<meta property="og:type" content="website"/> <meta property="og:type" content="website"/>
<meta property="og:title" content="{{board.Board}}"/> <meta property="og:title" content="{{board.Board}}"/>
<meta property="og:description" content="thread no. {{thread.OP.PostHash}} on changolia"/> <meta property="og:description" content="thread no. {{thread.OP.PostHash}} on changolia"/>
<meta property="og:url" content="{{prefix}}t/{{thread.OP.PostHash}}/"/> <meta property="og:url" content="{{prefix}}t/{{thread.OP.PostHash}}/?lang={{i18n.Name}}"/>
<meta property="og:image" <meta property="og:image"
content="{{prefix}}static/changolia-logo.png"/> content="{{prefix}}static/changolia-logo.png"/>
</head> </head>
@ -32,10 +32,10 @@
{{{thread.Navbar}}} {{{thread.Navbar}}}
<hr /> <hr />
<div class="sitetitle"> <div class="sitetitle">
<h2><a href="{{thread.Prefix}}">CHANGOLIA</a></h2> <h2><a href="{{thread.Prefix}}?lang={{i18n.Name}}">CHANGOLIA</a></h2>
<b>Most of the rest of the wild west.</b> <b>Most of the rest of the wild west.</b>
</div> </div>
<center><b><a href="{{thread.BoardURL}}">{{thread.Board}}</a></b></center> <center><b><a href="{{thread.BoardURL}}?lang={{i18n.Name}}">{{thread.Board}}</a></b></center>
<br /> <br />
{{{form}}} {{{form}}}

View File

@ -19,7 +19,7 @@
<meta property="og:type" content="website"/> <meta property="og:type" content="website"/>
<meta property="og:title" content="overboard"/> <meta property="og:title" content="overboard"/>
<meta property="og:description" content="changolia overboard"/> <meta property="og:description" content="changolia overboard"/>
<meta property="og:url" content="{{prefix}}o/"/> <meta property="og:url" content="{{prefix}}o/?lang={{i18n.Name}}"/>
<meta property="og:image" <meta property="og:image"
content="{{prefix}}static/changolia-logo.png"/> content="{{prefix}}static/changolia-logo.png"/>
</head> </head>
@ -34,19 +34,19 @@
<div id="paginator"> <div id="paginator">
{{#prev}} {{#prev}}
<span id="prev"> <span id="prev">
<a href="{{prefix}}o/{{no}}/">previous</a> <a href="{{prefix}}o/{{no}}/?lang={{i18n.Name}}">previous</a>
</span> </span>
{{/prev}} {{/prev}}
{{#next}} {{#next}}
<span id="next"> <span id="next">
<a href="{{prefix}}o/{{no}}/">next</a> <a href="{{prefix}}o/{{no}}/?lang={{i18n.Name}}">next</a>
</span> </span>
{{/next}} {{/next}}
</div> </div>
{{#threads}} {{#threads}}
{{#Truncate}} {{#Truncate}}
<div class="thread" id="thread_{{OP.PostHash}}"> <div class="thread" id="thread_{{OP.PostHash}}">
Posted on <a href="{{BoardURL}}">{{Board}}</a> Posted on <a href="{{BoardURL}}?lang={{i18n.Name}}">{{Board}}</a>
<br /> <br />
{{{OP.RenderTruncatedPost}}} {{{OP.RenderTruncatedPost}}}
<div class="excluded">{{MissingPostCount}} posts excluded</div> <div class="excluded">{{MissingPostCount}} posts excluded</div>
@ -60,12 +60,12 @@
<div id="paginator"> <div id="paginator">
{{#prev}} {{#prev}}
<span id="prev"> <span id="prev">
<a href="{{prefix}}o/{{no}}/">previous</a> <a href="{{prefix}}o/{{no}}/?lang={{i18n.Name}}">previous</a>
</span> </span>
{{/prev}} {{/prev}}
{{#next}} {{#next}}
<span id="next"> <span id="next">
<a href="{{prefix}}o/{{no}}/">next</a> <a href="{{prefix}}o/{{no}}/?lang={{i18n.Name}}">next</a>
</span> </span>
{{/next}} {{/next}}
</div> </div>