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 (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"embed"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -10,7 +11,10 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
const DefaultTranslationPath = "java/gliffy/importer/gliffyTranslation.properties"
|
const DefaultTranslationPath = "gliffyTranslation.properties"
|
||||||
|
|
||||||
|
//go:embed gliffyTranslation.properties
|
||||||
|
var embeddedTranslations embed.FS
|
||||||
|
|
||||||
type StencilTranslator struct {
|
type StencilTranslator struct {
|
||||||
once sync.Once
|
once sync.Once
|
||||||
@@ -50,14 +54,18 @@ func (s *StencilTranslator) load() {
|
|||||||
if path == "" {
|
if path == "" {
|
||||||
path = DefaultTranslationPath
|
path = DefaultTranslationPath
|
||||||
}
|
}
|
||||||
file, err := os.Open(filepath.Clean(path))
|
var scanner *bufio.Scanner
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
s.translations = make(map[string]string)
|
s.translations = make(map[string]string)
|
||||||
scanner := bufio.NewScanner(file)
|
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := strings.TrimSpace(scanner.Text())
|
line := strings.TrimSpace(scanner.Text())
|
||||||
if line == "" || strings.HasPrefix(line, "#") {
|
if line == "" || strings.HasPrefix(line, "#") {
|
||||||
|
|||||||
Reference in New Issue
Block a user