49 lines
1.7 KiB
Go
49 lines
1.7 KiB
Go
// Fenrir console screen reader.
|
|
// Copyright (c) 2026 Storm Dragon
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify it
|
|
// under the terms of the GNU General Public License as published by the Free
|
|
// Software Foundation, either version 3 of the License, or (at your option)
|
|
// any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
// more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License along with
|
|
// this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
|
|
|
|
package presentation
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"git.stormux.org/storm/fenrir/internal/i18n"
|
|
"git.stormux.org/storm/fenrir/internal/screen"
|
|
)
|
|
|
|
func TestTranslationsDoNotTranslateApplicationContent(t *testing.T) {
|
|
root := t.TempDir()
|
|
dir := filepath.Join(root, "xx", "LC_MESSAGES")
|
|
if err := os.MkdirAll(dir, 0700); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(filepath.Join(dir, "fenrir.po"), []byte("msgid \"blank\"\nmsgstr \"translated-blank\"\n"), 0600); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
previous := i18n.Use(i18n.New(root, "xx"))
|
|
t.Cleanup(func() { i18n.Use(previous) })
|
|
snapshot := screen.Snapshot{Rows: 1, Cols: 5, Cells: []rune("blank")}
|
|
if got := Line(snapshot, 0); got != "blank" {
|
|
t.Fatal("translated application text", got)
|
|
}
|
|
snapshot.Cells = []rune(" ")
|
|
if got := Line(snapshot, 0); got != "translated-blank" {
|
|
t.Fatal("reader label untranslated", got)
|
|
}
|
|
}
|