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