Docs i18n: harden doc-mode pipeline

This commit is contained in:
Josh Palmer
2026-02-01 22:47:33 +01:00
parent da9f28d270
commit e70984745b
7 changed files with 760 additions and 37 deletions

View File

@@ -52,7 +52,7 @@ func LoadTranslationMemory(path string) (*TranslationMemory, error) {
if err := json.Unmarshal([]byte(trimmed), &entry); err != nil {
return nil, fmt.Errorf("translation memory decode failed: %w", err)
}
if entry.CacheKey != "" {
if entry.CacheKey != "" && strings.TrimSpace(entry.Translated) != "" {
tm.entries[entry.CacheKey] = entry
}
}
@@ -69,7 +69,13 @@ func LoadTranslationMemory(path string) (*TranslationMemory, error) {
func (tm *TranslationMemory) Get(cacheKey string) (TMEntry, bool) {
entry, ok := tm.entries[cacheKey]
return entry, ok
if !ok {
return TMEntry{}, false
}
if strings.TrimSpace(entry.Translated) == "" {
return TMEntry{}, false
}
return entry, true
}
func (tm *TranslationMemory) Put(entry TMEntry) {