Skip to content

Commit

Permalink
removed debugging code
Browse files Browse the repository at this point in the history
  • Loading branch information
allmightyspiff committed May 24, 2024
1 parent 89ff530 commit 7ff73f1
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions plugin/i18n/i18n.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package i18n

import (
"path/filepath"
"embed"
"strings"
"golang.org/x/text/language"
Expand All @@ -10,7 +9,6 @@ import (
"github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/configuration/core_config"
"github.com/Xuanwo/go-locale"
goi18n "github.com/nicksnyder/go-i18n/v2/i18n"
// "github.ibm.com/SoftLayer/softlayer-cli/plugin/resources"
)

//go:embed v2Resources/active.*.json
Expand All @@ -33,37 +31,14 @@ var SUPPORTED_LOCALES = []string{
"zh_Hant",
}

var resourcePath = filepath.Join("plugin", "i18n", "v2Resources")
var localizer = Init()


// var matcher = InitMatcher()


// func InitMatcher() language.Matcher {
// var supported []language.Tag
// for _, lang := range SUPPORTED_LOCALES {
// supported = append(supported, language.MustParse(lang))
// }
// return language.NewMatcher(supported)
// }

func GetResourcePath() string {
return resourcePath
}

func SetResourcePath(path string) {
resourcePath = path
}

// var T goi18n.TranslateFunc = Init(core_config.NewCoreConfig(func(error) {}))

// Translates a string, with any substitutions needed
// text: string to be translated
// subs: A single map[string]interface{}
func T(text string, subs ...interface{}) string {

// fmt.Printf("SUBS: %v\n", subs)
config := &goi18n.LocalizeConfig{
DefaultMessage: &goi18n.Message{ID: text, Other: text, One: text},
}
Expand All @@ -75,14 +50,12 @@ func T(text string, subs ...interface{}) string {

l_string, err := localizer.Localize(config)
if err != nil {
fmt.Printf("ERROR i18n: %v\n", err.Error())
// fmt.Printf("ERROR i18n: %v\n", err.Error())
// return err.Error()
}
return l_string
}



// Sets the localizer, reads local from config/system
func Init() *goi18n.Localizer {

Expand Down Expand Up @@ -117,7 +90,6 @@ func SetLocalizer(new_localizer *goi18n.Localizer) {
localizer = new_localizer
}


// Tries to determine the system locale, when local isn't set, default to en_US
func DetectLocal() string {
tag, err := locale.Detect()
Expand All @@ -129,7 +101,6 @@ func DetectLocal() string {
return locale
}


// Tries to match the system locale with a supported locale, otherwise sets a DEFAULT_LOCALE
func supportedLocale(configLocal string) string {

Expand Down

0 comments on commit 7ff73f1

Please sign in to comment.