Skip to content

Commit 8855fbe

Browse files
committed
New: Translate page names in PDFs
1 parent 5dfc9ed commit 8855fbe

17 files changed

+24
-43
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1616
- Improved touch screen navigation (swipe gesture, 2 finger zoom and reset zoom with 2 finger click) [`f848463`](https://github.com/ollm/OpenComic/commit/f84846399f1521c736b9b6e048f204513ac304da)
1717
- Improved detection of image edges when zoom is applied [`e7ec771`](https://github.com/ollm/OpenComic/commit/e7ec77104360b1e2ac2aa96d97b6c1d2cc2d6d01)
1818
- Frameless window (Full only in Windows and macOS) [`9c7346c`](https://github.com/ollm/OpenComic/commit/9c7346cb37fe3c7aed9200d49e27ed4c5bdbfc96)
19+
- Translate page names in PDFs
1920

2021
##### 🐛 Bug Fixes
2122

languages/ca.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"settings": "Configuració",
4848
"theme": "Tema",
4949
"days": "Dies",
50+
"pageAndNumber": "Pàgina $1",
5051
"valueCannotBeEmpty": "El valor no pot estar buit",
5152
"nightMode": "Mode nit"
5253
},

languages/cs.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"settings": "",
4848
"theme": "Vzhled",
4949
"days": "",
50+
"pageAndNumber": "",
5051
"valueCannotBeEmpty": "Hodnota nesmí být prázdná",
5152
"nightMode": "Noční režim"
5253
},

languages/de.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"settings": "",
4848
"theme": "Thema",
4949
"days": "",
50+
"pageAndNumber": "",
5051
"valueCannotBeEmpty": "",
5152
"nightMode": "Nachtmodus"
5253
},

languages/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"settings": "Settings",
4848
"theme": "Theme",
4949
"days": "Days",
50+
"pageAndNumber": "Page $1",
5051
"valueCannotBeEmpty": "Value cannot be empty",
5152
"nightMode": "Night mode"
5253
},

languages/es.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"settings": "Ajustes",
4848
"theme": "Tema",
4949
"days": "Días",
50+
"pageAndNumber": "Página $1",
5051
"valueCannotBeEmpty": "El valor no puede estar vació",
5152
"nightMode": "Modo noche"
5253
},

languages/fr.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"settings": "",
4848
"theme": "Theme",
4949
"days": "",
50+
"pageAndNumber": "",
5051
"valueCannotBeEmpty": "",
5152
"nightMode": "Mode nuit"
5253
},

languages/hu.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"settings": "",
4848
"theme": "Téma",
4949
"days": "",
50+
"pageAndNumber": "",
5051
"valueCannotBeEmpty": "",
5152
"nightMode": "Sötét téma"
5253
},

languages/it.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"settings": "",
4848
"theme": "Tema",
4949
"days": "",
50+
"pageAndNumber": "",
5051
"valueCannotBeEmpty": "",
5152
"nightMode": "Modalità notte"
5253
},

languages/ja.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"settings": "",
4848
"theme": "テーマ",
4949
"days": "",
50+
"pageAndNumber": "",
5051
"valueCannotBeEmpty": "",
5152
"nightMode": "ナイトモード"
5253
},

languages/pt-br.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"settings": "",
4848
"theme": "Tema",
4949
"days": "",
50+
"pageAndNumber": "",
5051
"valueCannotBeEmpty": "",
5152
"nightMode": "Modo Noturno"
5253
},

languages/ru.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"settings": "",
4848
"theme": "Тема",
4949
"days": "",
50+
"pageAndNumber": "",
5051
"valueCannotBeEmpty": "Значение не может быть пустым",
5152
"nightMode": "Ночной режим"
5253
},

languages/vi.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"settings": "",
4848
"theme": "Chủ đề",
4949
"days": "",
50+
"pageAndNumber": "",
5051
"valueCannotBeEmpty": "Giá trị không được để trống",
5152
"nightMode": "Chế độ tối"
5253
},

languages/zh-hans.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"settings": "",
4848
"theme": "主题",
4949
"days": "",
50+
"pageAndNumber": "",
5051
"valueCannotBeEmpty": "",
5152
"nightMode": "夜间模式"
5253
},

languages/zh-hant.json

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"settings": "",
4848
"theme": "圖形介面",
4949
"days": "",
50+
"pageAndNumber": "",
5051
"valueCannotBeEmpty": "",
5152
"nightMode": "夜間模式"
5253
},

scripts/dom.js

+7-41
Original file line numberDiff line numberDiff line change
@@ -116,44 +116,6 @@ function getReadingProgress(path, callback)
116116
return false;
117117
}
118118

119-
function calcReadingProgress(path, mainPath, callback)
120-
{
121-
(function(path, mainPath, callback){
122-
123-
process.nextTick(function() {
124-
125-
var progress = calcReadingProgressWD(path, mainPath, callback);
126-
127-
if(checkError(progress))
128-
{
129-
(function(error, path, mainPath, callback){
130-
131-
fileCompressed.addCompressedFilesQueue(error.compressedPath, false, function(files){
132-
133-
if(!checkError(files))
134-
dom.calcReadingProgress(path, mainPath, callback);
135-
else
136-
callback(files);
137-
138-
});
139-
140-
})(progress, path, mainPath, callback)
141-
}
142-
else
143-
{
144-
if(callback)
145-
callback(progress);
146-
}
147-
});
148-
149-
})(path, mainPath, callback);
150-
}
151-
152-
function calcReadingProgressWD()
153-
{
154-
155-
}
156-
157119
function addImageToDom(querySelector, path, animation = true)
158120
{
159121
let backgroundImage = 'url('+path+')';
@@ -174,6 +136,11 @@ function addImageToDom(querySelector, path, animation = true)
174136
}
175137
}
176138

139+
function translatePageName(name)
140+
{
141+
return name.replace(/^page\-([0-9]+)/, language.global.pageAndNumber);
142+
}
143+
177144
async function loadFilesIndexPage(file, animation, path, keepScroll, mainPath)
178145
{
179146
return file.read().then(async function(files){
@@ -232,7 +199,7 @@ async function loadFilesIndexPage(file, animation, path, keepScroll, mainPath)
232199

233200
pathFiles.push({
234201
sha: sha,
235-
name: fileName.replace(/\.[^\.]*$/, ''),
202+
name: translatePageName(fileName.replace(/\.[^\.]*$/, '')),
236203
path: filePath,
237204
mainPath: mainPath,
238205
thumbnail: (thumbnail.cache) ? thumbnail.path : '',
@@ -1570,8 +1537,6 @@ module.exports = {
15701537
addComicButtons: addComicButtons,
15711538
comicContextMenu: comicContextMenu,
15721539
removeComic: removeComic,
1573-
calcReadingProgress: calcReadingProgress,
1574-
calcReadingProgressWD: calcReadingProgressWD,
15751540
compressedError: compressedError,
15761541
addImageToDom: addImageToDom,
15771542
addSepToEnd: addSepToEnd,
@@ -1581,6 +1546,7 @@ module.exports = {
15811546
indexMainPathA: function(){return indexMainPathA},
15821547
currentPathScrollTop: function(){return currentPathScrollTop},
15831548
getFolderThumbnails: getFolderThumbnails,
1549+
translatePageName: translatePageName,
15841550
search: search,
15851551
this: domManager.this,
15861552
query: domManager.query,

scripts/reading.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2788,7 +2788,7 @@ function loadBookmarks()
27882788
});
27892789

27902790
bookmarksPath[bookmarkDirname].push({
2791-
name: decodeURI(p.basename(bookmark.path).replace(/\.[^\.]*$/, '')),
2791+
name: dom.translatePageName(decodeURI(p.basename(bookmark.path).replace(/\.[^\.]*$/, ''))),
27922792
index: (bookmarkDirname !== readingCurrentPath) ? bookmark.index : imagesPath[bookmark.path],
27932793
sha: sha,
27942794
mainPath: mainPath,
@@ -2840,7 +2840,7 @@ function loadBookmarks()
28402840
path: bookmarkDirname,
28412841
name: p.basename(bookmarkDirname),
28422842
bookmarks: [{
2843-
name: decodeURI(p.basename(readingProgress.path).replace(/\.[^\.]*$/, '')),
2843+
name: dom.translatePageName(decodeURI(p.basename(readingProgress.path).replace(/\.[^\.]*$/, ''))),
28442844
index: readingProgress.index,
28452845
sha: sha,
28462846
mainPath: readingProgress.mainPath,

0 commit comments

Comments
 (0)