Skip to content

Commit

Permalink
Merge pull request #59 from webability-go/late-night
Browse files Browse the repository at this point in the history
patch v2.0.3
  • Loading branch information
metalwolf committed Apr 8, 2020
2 parents cf37d7c + 522151d commit 17b8738
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
4 changes: 4 additions & 0 deletions v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ Some improvements to check, later:
Version Changes Control
=======================

v2.0.3 - 2020-04-08
-----------------------
- XLanguage: Error corrected on loadXMLString: the data was not loading correctly into the XLanguage object.

v2.0.1, v2.0.2 - 2020-03-29
-----------------------
- Version adjustment for github and go modules v2
Expand Down
2 changes: 1 addition & 1 deletion v2/xcore.go
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@
package xcore

// VERSION is the used version nombre of the XCore library.
const VERSION = "2.0.0"
const VERSION = "2.0.3"

// LOG is the flag to activate logging on the library.
// if LOG is set to TRUE, LOG indicates to the XCore libraries to log a trace of functions called, with most important parameters.
Expand Down
15 changes: 4 additions & 11 deletions v2/xlanguage.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,7 @@ func NewXLanguageFromString(data string) (*XLanguage, error) {
// LoadXMLFile will Load a language from an XML file and replace the content of the XLanguage structure with the new data
// Returns nil if there is an error
func (l *XLanguage) LoadXMLFile(file string) error {
xmlFile, err := os.Open(file)
if err != nil {
return err
}
data, err := ioutil.ReadAll(xmlFile)
if err != nil {
return err
}
err = xmlFile.Close()
data, err := ioutil.ReadFile(file)
if err != nil {
return err
}
Expand All @@ -100,20 +92,21 @@ func (l *XLanguage) LoadXMLString(data string) error {
type xlang struct {
Name string `xml:"id,attr"`
Language string `xml:"lang,attr"`
entries []xentry `xml:"entry"`
Entries []xentry `xml:"entry"`
}

// Unmarshal
temp := &xlang{}
err := xml.Unmarshal([]byte(data), temp)

if err != nil {
return err
}

// Scan to our XLanguage Object
l.Name = temp.Name
l.Language, _ = language.Parse(temp.Language)
for _, e := range temp.entries {
for _, e := range temp.Entries {
l.entries[e.ID] = e.Entry
}
return nil
Expand Down
2 changes: 1 addition & 1 deletion v2/xlanguage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestXLanguage(t *testing.T) {
}
v2 := loadxmlES.Get(id)
if v2 != val {
// t.Errorf("Error reading value of loadxmlES::%s", v2)
t.Errorf("Error reading value of loadxmlES::%s", v2)
return
}
v3 := loadtextES.Get(id)
Expand Down

0 comments on commit 17b8738

Please sign in to comment.