add translation properties to git

This commit is contained in:
2026-01-06 20:19:59 +11:00
parent 20b984bb58
commit 8d98c9f453
2 changed files with 2234 additions and 5 deletions

2221
gliffyTranslation.properties Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -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, "#") {