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
7 changed files with 22 additions and 18 deletions

View File

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

View File

@@ -486,7 +486,11 @@ func (self *post) Attachments() []AttachmentModel {
}
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 {

View File

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