mirror of
https://github.com/aleksey-hoffman/sigma-file-manager.git
synced 2026-10-19 01:31:05 -05:00
Dev: keep locale JSON files ending with a newline
This commit is contained in:
1 parent
588165e688
commit
a4d4f4f1c1
17 files changed
+65
-15
No files matched your search
@@ -7,3 +7,11 @@ trim_trailing_whitespace = true
|
||||
|
||||
end_of_line = lf
|
||||
max_line_length = 100
|
||||
|
||||
[*.json]
|
||||
charset = utf-8
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
end_of_line = lf
|
||||
+16
-1
@@ -48,6 +48,21 @@ function removeUnneededKeys(enLocale, otherLocale) {
|
||||
return otherLocale;
|
||||
}
|
||||
|
||||
function formatLocaleJson(localePayload) {
|
||||
return `${JSON.stringify(localePayload, null, 2)}\n`;
|
||||
}
|
||||
|
||||
function writeLocaleFile(filePath, localePayload) {
|
||||
const nextContent = formatLocaleJson(localePayload);
|
||||
const currentContent = fs.existsSync(filePath)
|
||||
? fs.readFileSync(filePath, 'utf8')
|
||||
: '';
|
||||
|
||||
if (currentContent !== nextContent) {
|
||||
fs.writeFileSync(filePath, nextContent);
|
||||
}
|
||||
}
|
||||
|
||||
function syncFiles() {
|
||||
const englishPayload = JSON.parse(fs.readFileSync(path.join(localeDirectoryPath, 'en.json'), 'utf8'));
|
||||
|
||||
@@ -60,7 +75,7 @@ function syncFiles() {
|
||||
const localePayload = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
||||
addMissingKeys(englishPayload, localePayload);
|
||||
removeUnneededKeys(englishPayload, localePayload);
|
||||
fs.writeFileSync(filePath, `${JSON.stringify(localePayload, null, 2)}\n`);
|
||||
writeLocaleFile(filePath, localePayload);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// License: GNU GPLv3 or later. See the license file in the project root for more information.
|
||||
// Copyright © 2021 - present Aleksey Hoffman. All rights reserved.
|
||||
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
const localeDirectoryPath = path.resolve('src/localization/messages');
|
||||
|
||||
describe('locale json format', () => {
|
||||
const localeFileNames = fs.readdirSync(localeDirectoryPath).filter(
|
||||
fileName => fileName.endsWith('.json'),
|
||||
);
|
||||
|
||||
it('uses lf line endings and exactly one trailing newline', () => {
|
||||
expect(localeFileNames.length).toBeGreaterThan(0);
|
||||
|
||||
for (const fileName of localeFileNames) {
|
||||
const fileContent = fs.readFileSync(path.join(localeDirectoryPath, fileName), 'utf8');
|
||||
|
||||
expect(fileContent.includes('\r'), fileName).toBe(false);
|
||||
expect(fileContent.endsWith('\n'), fileName).toBe(true);
|
||||
expect(fileContent.endsWith('\n\n'), fileName).toBe(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1293,4 +1293,4 @@
|
||||
"replaceShareDialogDescription": "文件已在网络上共享。当前共享将被停止并替换为新的共享。",
|
||||
"replaceShareDialogConfirm": "替换"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1293,4 +1293,4 @@
|
||||
"replaceShareDialogDescription": "Files are already being shared over the network. The current share will be stopped and replaced with the new one.",
|
||||
"replaceShareDialogConfirm": "Replace"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1293,4 +1293,4 @@
|
||||
"replaceShareDialogDescription": "فایلها از قبل از طریق شبکه به اشتراک گذاشته شدهاند. اشتراکگذاری فعلی متوقف و با مورد جدید جایگزین خواهد شد.",
|
||||
"replaceShareDialogConfirm": "جایگزینی"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1293,4 +1293,4 @@
|
||||
"replaceShareDialogDescription": "קבצים כבר משותפים ברשת. השיתוף הנוכחי ייעצר ויוחלף בחדש.",
|
||||
"replaceShareDialogConfirm": "החלף"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1293,4 +1293,4 @@
|
||||
"replaceShareDialogDescription": "फ़ाइलें पहले से ही नेटवर्क पर साझा की जा रही हैं. वर्तमान शेयर बंद कर दिया जाएगा और उसके स्थान पर नया शेयर ले लिया जाएगा।",
|
||||
"replaceShareDialogConfirm": "प्रतिस्थापित करें"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1293,4 +1293,4 @@
|
||||
"replaceShareDialogDescription": "Ֆայլերն արդեն կիսվում են ցանցում: Ընթացիկ կիսումը կդադարեցվի և կփոխարինվի նորով:",
|
||||
"replaceShareDialogConfirm": "Փոխարինել"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1293,4 +1293,4 @@
|
||||
"replaceShareDialogDescription": "Ci sono già file condivisi in rete. La condivisione attuale verrà interrotta e sostituita con quella nuova.",
|
||||
"replaceShareDialogConfirm": "Sostituisci"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1293,4 +1293,4 @@
|
||||
"replaceShareDialogDescription": "すでにネットワーク上でファイルが共有されています。現在の共有を停止し、新しいものに置き換えます。",
|
||||
"replaceShareDialogConfirm": "置き換え"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1293,4 +1293,4 @@
|
||||
"replaceShareDialogDescription": "Já existem arquivos sendo compartilhados na rede. O compartilhamento atual será interrompido e substituído pelo novo.",
|
||||
"replaceShareDialogConfirm": "Substituir"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1293,4 +1293,4 @@
|
||||
"replaceShareDialogDescription": "Файлы уже доступны по сети. Текущий доступ будет остановлен и заменён новым.",
|
||||
"replaceShareDialogConfirm": "Заменить"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1293,4 +1293,4 @@
|
||||
"replaceShareDialogDescription": "Datoteke se že delijo po omrežju. Trenutno deljenje bo ustavljeno in zamenjano z novim.",
|
||||
"replaceShareDialogConfirm": "Zamenjaj"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1293,4 +1293,4 @@
|
||||
"replaceShareDialogDescription": "Ağ üzerinden zaten dosyalar paylaşılıyor. Mevcut paylaşım durdurulup yenisiyle değiştirilecek.",
|
||||
"replaceShareDialogConfirm": "Değiştir"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1293,4 +1293,4 @@
|
||||
"replaceShareDialogDescription": "فائلیں پہلے سے نیٹ ورک پر ہیں۔ موجودہ شیئر بند ہو کر نئے سے بدل جائے گا۔",
|
||||
"replaceShareDialogConfirm": "بدل دیں"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1293,4 +1293,4 @@
|
||||
"replaceShareDialogDescription": "Các tập tin đang được chia sẻ qua mạng. Chia sẻ hiện tại sẽ bị dừng và thay thế bằng chia sẻ mới.",
|
||||
"replaceShareDialogConfirm": "Thay thế"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user