xml

package
v0.0.0-...-d9d29f0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package xml specifies functions and structs for writing dictionaries to xml files and android project res folder

Index

Constants

View Source
const (
	// ValuesPrefix defines the default prefix for values folder
	ValuesPrefix = "values-"
	// StringsFilename defines the default filename for android string constants file
	StringsFilename = "strings.xml"
	// ExportFileMode defines the default permissions for created file
	ExportFileMode = 0750
)

Variables

This section is empty.

Functions

func ReadResFolder

func ReadResFolder(path string) (dicts general.Dictionaries, err error)

ReadResFolder reads and unmarshals all strings.xml files in the "res" folder

func WriteResFolder

func WriteResFolder(path string, dicts general.Dictionaries) (files []*os.File, err error)

WriteResFolder writes the given set of dictionaries to the res folder at the given path

Types

type ResourcesEntry

type ResourcesEntry struct {
	XMLName xml.Name      `xml:"resources"` // name of xml tag
	Strings []StringEntry `xml:"string"`    // strings itself
}

ResourcesEntry struct defines a node of <resources></resources> tag in xml file

func ReadXMLFile

func ReadXMLFile(path string) (r *ResourcesEntry, err error)

ReadXMLFile unmarshals structure of strings.xml file and returns its content

func (*ResourcesEntry) ConvertToDictionary

func (r *ResourcesEntry) ConvertToDictionary() (d general.Dictionary)

ConvertToDictionary converts the given ResourcesEntry to the dictionary map[code]translation

func (*ResourcesEntry) WriteToXMLFile

func (r *ResourcesEntry) WriteToXMLFile(path string) (file *os.File, err error)

WriteToXMLFile marshals and writes xml structure of ResourcesEntry to the specified file

type StringEntry

type StringEntry struct {
	XMLName xml.Name `xml:"string"`    // name of xml tag
	Name    string   `xml:"name,attr"` // name attribute of xml tag
	Value   string   `xml:",innerxml"` // value of xml string tag
}

StringEntry struct defines a node of <string></string> tag in xml file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL