add translation properties to git
This commit is contained in:
2221
gliffyTranslation.properties
Normal file
2221
gliffyTranslation.properties
Normal file
File diff suppressed because it is too large
Load Diff
18
mapping.go
18
mapping.go
@@ -2,6 +2,7 @@ package gliffy2drawio
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"embed"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -10,7 +11,10 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
const DefaultTranslationPath = "java/gliffy/importer/gliffyTranslation.properties"
|
||||
const DefaultTranslationPath = "gliffyTranslation.properties"
|
||||
|
||||
//go:embed gliffyTranslation.properties
|
||||
var embeddedTranslations embed.FS
|
||||
|
||||
type StencilTranslator struct {
|
||||
once sync.Once
|
||||
@@ -50,14 +54,18 @@ func (s *StencilTranslator) load() {
|
||||
if path == "" {
|
||||
path = DefaultTranslationPath
|
||||
}
|
||||
file, err := os.Open(filepath.Clean(path))
|
||||
if err != nil {
|
||||
var scanner *bufio.Scanner
|
||||
if f, err := os.Open(filepath.Clean(path)); err == nil {
|
||||
defer f.Close()
|
||||
scanner = bufio.NewScanner(f)
|
||||
} else if data, err2 := embeddedTranslations.Open(path); err2 == nil {
|
||||
defer data.Close()
|
||||
scanner = bufio.NewScanner(data)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
s.translations = make(map[string]string)
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
line := strings.TrimSpace(scanner.Text())
|
||||
if line == "" || strings.HasPrefix(line, "#") {
|
||||
|
||||
Reference in New Issue
Block a user