<commit_before>package config

import (
	"fmt"
	"strings"

	"github.com/pkg/errors"
	"github.com/xshellinc/tools/constants"
	"github.com/xshellinc/tools/dialogs"
	"github.com/xshellinc/tools/lib/help"
	"github.com/xshellinc/tools/lib/ssh_helper"
)

// SetLocale is a default method to with dialog to configure the locale
func SetLocale(storage map[string]interface{}) error {

	fmt.Println("[+] Default language: ", constants.DefaultLocale)
	if dialogs.YesNoDialog("Change default language?") {
		inp := dialogs.GetSingleAnswer("New locale: ", dialogs.EmptyStringValidator, dialogs.CreateValidatorFn(constants.ValidateLocale))

		arr, _ := constants.GetLocale(inp)

		var l string
		if len(arr) == 1 {
			l = arr[0]
		} else {
			l = arr[dialogs.SelectOneDialog("Please select a locale from a list: ", arr)]
		}

		storage[GetConstLiteral(Locale)] = strings.Split(l, " ")[0]
	}

	return nil
}

// SaveLocale is a default method to save locale into the image
func SaveLocale(storage map[string]interface{}) error {
<commit_msg>ADDED descriptive list of locales #44<commit_after>package config

import (
	"fmt"

	"github.com/pkg/errors"
	"github.com/xshellinc/tools/constants"
	"github.com/xshellinc/tools/dialogs"
	"github.com/xshellinc/tools/lib/help"
	"github.com/xshellinc/tools/lib/ssh_helper"
)

func localesToStrings(locales []*constants.Locale) []string {
	out := make([]string, len(locales))
	for i, l := range locales {
		out[i] = l.String()
	}
	return out
}

// SetLocale is a default method to with dialog to configure the locale
func SetLocale(storage map[string]interface{}) error {

	fmt.Println("[+] Default language: ", constants.DefaultLocale)
	if dialogs.YesNoDialog("Change default language?") {
		inp := dialogs.GetSingleAnswer("New locale: ", dialogs.EmptyStringValidator, dialogs.CreateValidatorFn(constants.ValidateLocale))

		arr := constants.GetLocale(inp)

		var l string
		if len(arr) == 1 {
			l = arr[0].Locale
		} else {
			l = arr[dialogs.SelectOneDialog("Please select a locale from a list: ", localesToStrings(arr))].Locale
		}

		storage[GetConstLiteral(Locale)] = l
	}

	return nil
}

// SaveLocale is a default method to save locale into the image
func SaveLocale(storage map[string]interface{}) error {

{'fraction_non_alphanumeric': 0.12952210808396605, 'fraction_numerical': 0.0031263957123715946, 'mean_word_length': 4.743589743589744, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2197134', 'n_tokens_mistral': 773, 'n_tokens_neox': 737, 'n_words': 177}