Documentation ¶
Index ¶
- Constants
- Variables
- func CreateResourceFile(t types.FileType) (*os.File, error)
- func DeleteResourceFile() error
- func GetArrayString(name string) []string
- func GetQuantityString(name string, count int) string
- func GetString(name string) string
- func LoadValues(t types.FileType) error
- func NewQuantityString(name string, values []string) (types.Plural, error)
- func NewString(name, value string) (types.String, error)
- func NewStringArray(name string, values []string) (types.StringArray, error)
- func SetFewThreshold(value int)
- func SetResourceType(t types.FileType)
Constants ¶
Variables ¶
var ( ErrorEmptyStringName error = errors.New("stres: string name can't be empty") ErrorEmptyStringArrayName error = errors.New("stres: string-array name can't be empty") ErrorEmptyQuantityStringName error = errors.New("stres: quantity string name can't be empty") ErrorDuplicateStringName error = errors.New("stres: string name already inserted") ErrorDuplicateStringArrayName error = errors.New("stres: string-array name already inserted") ErrorDuplicateQuantityStringName error = errors.New("stres: quantity string name already inserted") ErrorQuantityStringPluralNotFound error = errors.New("stres: plural not found for the given quantity") ErrorQuantityStringEmptyValues error = errors.New("stres: provided empty array to quantity string creationg") )
Functions ¶
func CreateResourceFile ¶
Creates strings resource file in "strings" directory, throws an error otherwise. Takes a FileType parameter to specify strings file format.
func DeleteResourceFile ¶
func DeleteResourceFile() error
Deletes resource file if exists, throws an error otherwise. Uses setted resource file extension.
func GetArrayString ¶
Returns the string-array resource's values with the given name. If not exists, returns nil.
func GetQuantityString ¶
Returns the quantity string resource's corresponding string value based on the value of the given count parameter. If the plural is not found, returns an empty string.
func GetString ¶
Returns the string resource's value with the given name. If not exists, returns empty string.
func LoadValues ¶
Loads values from strings file into internal dictionaries. Needs to be invoked only one time (but before getting strings values). Takes a FileType parameter to specify strings file format.
func NewQuantityString ¶
Adds a new quantity string resource to resource file. Throws an error if the chosen name is already inserted or it is an empty string. The function uses only the first 5 values in the array. The first values is assigned to "zero" quantity. The second values is assigned to "one" quantity. The third values is assigned to "two" quantity. The fourth values is assigned to "few" quantity. The fifth values is assigned to "more" quantity.
func NewString ¶
Adds a new string resource to resource file. Throws an error if the chosen name is already inserted or it is an empty string.
func NewStringArray ¶
func NewStringArray(name string, values []string) (types.StringArray, error)
Adds a new string-array resource to resource file. Throws an error if the chosen name is already inserted or it is an empty string.
func SetFewThreshold ¶
func SetFewThreshold(value int)
Sets the threshold for "few" values in quantity strings. When getting quantity strings values, the function checks if the given count is less OR EQUAL to this value. (default value: 20)
func SetResourceType ¶
Types ¶
This section is empty.