taldir

Directory service to resolve wallet mailboxes by messenger addresses
Log | Files | Refs | Submodules | README | LICENSE

catalog.go (1162B)


      1 // Copyright 2015 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 package message
      6 
      7 // TODO: some types in this file will need to be made public at some time.
      8 // Documentation and method names will reflect this by using the exported name.
      9 
     10 import (
     11 	"golang.org/x/text/language"
     12 	"golang.org/x/text/message/catalog"
     13 )
     14 
     15 // MatchLanguage reports the matched tag obtained from language.MatchStrings for
     16 // the Matcher of the DefaultCatalog.
     17 func MatchLanguage(preferred ...string) language.Tag {
     18 	c := DefaultCatalog
     19 	tag, _ := language.MatchStrings(c.Matcher(), preferred...)
     20 	return tag
     21 }
     22 
     23 // DefaultCatalog is used by SetString.
     24 var DefaultCatalog catalog.Catalog = defaultCatalog
     25 
     26 var defaultCatalog = catalog.NewBuilder()
     27 
     28 // SetString calls SetString on the initial default Catalog.
     29 func SetString(tag language.Tag, key string, msg string) error {
     30 	return defaultCatalog.SetString(tag, key, msg)
     31 }
     32 
     33 // Set calls Set on the initial default Catalog.
     34 func Set(tag language.Tag, key string, msg ...catalog.Message) error {
     35 	return defaultCatalog.Set(tag, key, msg...)
     36 }