-
-
Notifications
You must be signed in to change notification settings - Fork 285
/
2.trans.py
3405 lines (3117 loc) · 136 KB
/
2.trans.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import os
import re
import shutil
from settings import BASE_FOLDER, PATCH_FOLDER, TRANSLATOR_URL, LANG
from translations import translation_dict
script_path = os.path.dirname(os.path.abspath(__file__))
BASE_PATH = f'{BASE_FOLDER}trilium-src/'
CLIENT_PATH = f'{BASE_FOLDER}trilium-linux-x64/'
PATCH_FOLDER = PATCH_FOLDER
TARGET_PATH = f'{CLIENT_PATH}resources/app/'
os.chdir(BASE_PATH)
TRANSLATOR_LABEL = translation_dict['translator']
if not os.path.exists(f'{TARGET_PATH}src/public/'):
os.system(f'cd {CLIENT_PATH}resources && asar extract app.asar ./app/')
# 是否要翻译属性标签(可能会影响代码, 小心使用)
# Whether to translate the note tag(may BREAK the code, use with care)
TRANSLATE_NOTE_TAG = True
# 用 {{}} 来标记要翻译的内容
# use {{}} to mark the content you want to translate
# .js文件修改源码再编译 复制
# .js files need to use the source code to compile
# .ejs 文件直接修改
# .ejs files will directly use the release files
pat = re.compile('{{(.*?)}}', flags=re.DOTALL + re.MULTILINE)
# check which file is not in use anymore
missing_files = []
# check which translation is not in use anymore
used_translations = [
'translator',
]
unused_translations = []
missing_translations = []
def translate(m):
s = m.group(1)
trans = translation_dict.get(s, None)
if not trans:
trans = s
missing_translations.append(s)
else:
used_translations.append(s)
return trans
def replace_in_file(file_path, translation, base_path=BASE_PATH):
file_full_path = os.path.join(base_path, file_path)
if not os.path.exists(file_full_path):
missing_files.append(file_path)
return
with open(file_full_path, 'r') as f:
content = f.read()
for ori_mark in translation:
ori_content = ori_mark.replace('{{', '').replace('}}', '')
trans = pat.sub(translate, ori_mark)
# print('ori_content', ori_content)
# print('11111trans', trans)
content = content.replace(ori_content, trans)
with open(file_full_path, 'w') as f:
f.write(content)
# 关于页面添加翻译者信息
# add translator info in about page :)
print('add translator info in about page.')
# before 0.53
# about_file_path = f'{TARGET_PATH}src/public/app/widgets/dialogs/about.js'
# 0.53.2
about_file_path = f'src/public/app/widgets/dialogs/about.js'
with open(about_file_path, 'r') as f:
content = f.read()
if TRANSLATOR_LABEL not in content:
content = content.replace(
' </table>',
f'\n <tr>\n <th>{TRANSLATOR_LABEL}:</th>\n <td><a href="{TRANSLATOR_URL}" class="external">{TRANSLATOR_URL}</a></td>\n </tr>\n </table>',
)
with open(about_file_path, 'w') as f:
f.write(content)
# Removed in 0.58.2
# # 修复flex布局下部分界面中文自动换行的问题
# # 选项界面
# file_path = 'src/public/app/widgets/dialogs/options.js'
# with open(file_path, 'r') as f:
# content = f.read()
# target_element = '<ul class="nav nav-tabs flex-column">'
# if target_element in content:
# content = content.replace('<ul class="nav nav-tabs flex-column">',
# '<ul class="nav nav-tabs flex-column" style="white-space: nowrap;">')
# with open(file_path, 'w') as f:
# f.write(content)
# 修复受保护的会话输入密码框样式
file_path = 'src/public/app/widgets/dialogs/protected_session_password.js'
with open(file_path, 'r') as f:
content = f.read()
target_element = ' <div class="form-group">\n <label>'
if target_element in content:
content = content.replace(
' <div class="form-group">\n <label>',
' <div class="form-group">\n <label style="width: -webkit-fill-available">',
)
with open(file_path, 'w') as f:
f.write(content)
# Removed in 0.58.2
# # 修复设置界面样式
# file_path = 'src/public/app/widgets/dialogs/options.js'
# with open(file_path, 'r') as f:
# content = f.read()
# target_element = ' <br/>\n <div class="tab-content">'
# if target_element in content:
# content = content.replace(' <br/>\n <div class="tab-content">',
# ' <br/>\n <div class="tab-content" style="width: -webkit-fill-available">')
# with open(file_path, 'w') as f:
# f.write(content)
# 升级属性
file_path = 'src/public/app/widgets/ribbon_widgets/promoted_attributes.js'
with open(file_path, 'r') as f:
content = f.read()
target_element = '<div class="promoted-attribute-cell">'
new_element = '<div class="promoted-attribute-cell" style="white-space: nowrap;">'
if target_element in content:
content = content.replace(target_element, new_element)
with open(file_path, 'w') as f:
f.write(content)
# 0.61 新增
# 附件功能 去掉复数名词后面的 s 字母
file_path = 'src/public/app/services/utils.js'
with open(file_path, 'r') as f:
content = f.read()
target_element = "const plural = (count, name) => `${count} ${name}${count > 1 ? 's' : ''}`;"
new_element = "const plural = (count, name) => `${count} ${name}`;"
if target_element in content:
content = content.replace(target_element, new_element)
with open(file_path, 'w') as f:
f.write(content)
# 下面一堆是正则匹配规则, 读代码的时候下面这一段可以跳过, 直接看最后面几行
# TL;DR, the following codes are regex matches, you can jump to the last few lines.
file_path = 'src/views/desktop.ejs'
translation = [
'>{{Trilium Notes}}<',
'>{{Trilium requires JavaScript to be enabled.}}<',
]
replace_in_file(file_path, translation, TARGET_PATH)
file_path = 'src/views/login.ejs'
translation = [
'>{{Login}}<',
'>{{Trilium login}}<',
'>{{Username}}<',
'>{{Password}}<',
'> {{Remember me}}',
'{{Username and / or password are incorrect. Please try again.}}',
]
replace_in_file(file_path, translation, TARGET_PATH)
file_path = 'src/views/mobile.ejs'
translation = [
'>{{Trilium Notes}}<',
'>{{Trilium requires JavaScript to be enabled.}}<',
]
replace_in_file(file_path, translation, TARGET_PATH)
file_path = 'src/views/set_password.ejs'
translation = [
'>{{Login}}<',
'>{{Set password}}<',
'>{{Before you can start using Trilium from web, you need to set a password first. You will then use this password to login.}}<',
'>{{Password}}<',
'>{{Password confirmation}}<',
]
replace_in_file(file_path, translation, TARGET_PATH)
file_path = 'src/views/setup.ejs'
translation = [
'>{{Setup}}<',
'>{{Trilium requires JavaScript to be enabled.}}<',
'>{{Trilium Notes setup}}<',
'>{{Next}}<',
'>{{New document}}<',
'>{{Username}}<',
'>{{Password}}<',
'>{{Repeat password}}<',
'>{{Theme}}<',
'>{{white}}<',
'>{{dark}}<',
'>{{light}}<',
'>{{black}}<',
'>{{Theme can be later changed in Options -> Appearance.}}<',
'>{{Back}}<',
'>{{Finish setup}}<',
'>{{Document initialization in progress}}<',
'>{{You will be shortly redirected to the application.}}<',
'>{{Sync from Desktop}}<',
'>{{This setup needs to be initiated from the desktop instance:}}<',
'>{{please open your desktop instance of Trilium Notes}}<',
'>{{click on Options button in the top right}}<',
'>{{click on Sync tab}}<',
'>{{configure server instance address to the: }}<',
'>{{ and click save.}}<',
'>{{click on "Test sync" button}}<',
">{{once you've done all this, click }}<",
'>{{here}}<',
'>{{Sync from Server}}<',
'>{{Please enter Trilium server address and credentials below. This will download the whole Trilium document from server and setup sync to it. Depending on the document size and your connection speed, this may take a while.}}<',
'>{{Trilium server address}}<',
'>{{Proxy server (optional)}}<',
'>{{Note:}}<',
'>{{ If you leave proxy setting blank, system proxy will be used (applies to desktop/electron build only)}}<',
'>{{Sync in progress}}<',
">{{Sync has been correctly set up. It will take some time for the initial sync to finish. Once it's done, you'll be redirected to the login page.}}<",
'>{{N/A}}<',
'{{Username and / or password are incorrect. Please try again.}}',
"{{I'm a new user, and I want to create a new Trilium document for my notes}}",
'{{I have a desktop instance already, and I want to set up sync with it}}',
'{{I have a server instance already, and I want to set up sync with it}}',
"{{You're almost done with the setup. The last thing is to choose username and password using which you'll login to the application.}}",
'{{This password is also used for generating encryption key which encrypts protected notes.}}',
'placeholder="{{Choose alphanumeric username}}"',
'placeholder="{{Username}}"',
'placeholder="{{Password}}"',
'{{Outstanding sync items}}:',
'{{Open your desktop instance of Trilium Notes.}}',
'>{{From the Trilium Menu, click Options.}}<',
'>{{Click on Sync tab.}}<',
'>{{Change server instance address to: }}<',
'>{{Click "Test sync" button to verify connection is successfull.}}<',
">{{Once you've completed these steps, click }}<",
]
replace_in_file(file_path, translation, TARGET_PATH)
file_path = 'src/views/share/404.ejs'
translation = [
'>{{Not found}}<',
]
replace_in_file(file_path, translation, TARGET_PATH)
file_path = 'src/views/share/page.ejs'
translation = [
'>{{This note was originally clipped from }}<',
'>{{This note has no content.}}<',
'>{{Child notes: }}<',
' {{parent: }}<',
]
replace_in_file(file_path, translation, TARGET_PATH)
file_path = 'src/public/app/menus/electron_context_menu.js'
translation = [
'title: `{{Add "${params.misspelledWord}" to dictionary}}`',
'title: `{{Cut}}',
'title: `{{Copy link}}`,',
'title: `{{Copy}} <kbd>',
'title: `{{Copy link}}`',
'title: `{{Paste as plain text}}',
'title: `{{Paste}}',
'title: {{`Search for "${shortenedSelection}" with ${searchEngineName}`}}',
]
replace_in_file(file_path, translation)
# file_path = 'src/public/app/widgets/dialogs/about.js'
# 0.53.2
file_path = 'src/public/app/widgets/dialogs/about.js'
translation = [
'>{{About Trilium Notes}}<',
'>{{Homepage:}}<',
'>{{App version:}}<',
'>{{DB version:}}<',
'>{{Sync version:}}<',
'>{{Build date:}}<',
'>{{Build revision:}}<',
'>{{Data directory:}}<',
]
# replace_in_file(file_path, translation, TARGET_PATH)
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/add_link.js'
translation = [
'>{{Add link}}<',
'>{{Note}}<',
'>{{Link title}}<',
'>{{Add link}} <',
'>{{enter}}<',
'title="{{Help on links}}"',
'{{search for note by its name}}',
"{{link title mirrors the note's current title}}",
'{{link title can be changed arbitrarily}}',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/branch_prefix.js'
translation = [
'>{{Edit branch prefix}}<',
'>{{Prefix}}: <',
'>{{Save}}<',
'title="{{Help on Tree prefix}}"',
'showMessage("{{Branch prefix has been saved.}}"',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/bulk_actions.js'
translation = [
'>{{Bulk actions}}<',
'>{{Bulk assign attributes}}<',
'>{{Affected notes: }}<',
' {{Include descendants of the selected notes}}',
'>{{Available actions}}<',
'>{{Chosen actions}}<',
'>{{Execute bulk actions}}<',
'>{{None yet ... add an action by clicking one of the available ones above.}}<',
'showMessage("{{Bulk actions have been executed successfully.}}"',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/clone_to.js'
translation = [
'>{{Clone notes to ...}}<',
'>{{Notes to clone}}<',
' {{Target parent note}}',
' {{Prefix (optional)}}',
'>{{Clone to selected note }}<',
'>{{enter}}<',
'title="{{Help on links}}"',
'title="{{Cloned note will be shown in note tree with given prefix}}"',
'{{search for note by its name}}',
'showMessage({{`Note "${clonedNote.title}" has been cloned into ${targetNote.title}`}}',
' logError("{{No path to clone to.}}"',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/confirm.js'
translation = [
'>{{Confirmation}}<',
'>{{Cancel}}<',
'>{{OK}}<',
'''.attr("title", "{{If you don't check this, the note will be only removed from the relation map.}}")''',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/delete_notes.js'
translation = [
'>{{Delete notes preview}}<',
'>{{Following notes will be deleted (}}<',
'>{{Following relations will be broken and deleted (}}<',
'>{{Cancel}}<',
'>{{OK}}<',
' {{delete also all clones}}',
'''title="{{Normal (soft) deletion only marks the notes as deleted and they can be undeleted (in recent changes dialog) within a period of time. Checking this option will erase the notes immediatelly and it won't be possible to undelete the notes.}}"''',
''' {{erase notes permanently (can't be undone). This will force application reload.}}''',
'{{can be undone in recent changes}}',
"{{erase notes permanently (can't be undone), including all clones. This will force application reload.}}",
'{{No note will be deleted (only clones).}}',
'.append(`{{Note}} `)',
'.append(`{{ (to be deleted) is referenced by relation <code>${attr.name}</code> originating from }}`)',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/export.js'
translation = [
'>{{Export note "}}<',
' {{this note and all of its descendants}}',
' {{HTML in ZIP archive - this is recommended since this preserves all the formatting.}}',
' {{OPML v1.0 - plain text only}}',
' {{OMPL v2.0 - allows also HTML}}',
' {{only this note without its descendants}}',
' {{HTML - this is recommended since this preserves all the formatting.}}',
'>{{Export}}<',
'{{this preserves most of the formatting.}}',
'{{outliner interchange format for text only. Formatting, images and files are not included.}}',
'title: "{{Export status}}"',
'showError("{{Choose export type first please}}"',
"throw new Error(`{{Unrecognized type}}",
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/help.js'
translation = [
'>{{Help (full documentation is available }}<',
'>{{online}}<',
'>{{Note navigation}}<',
'>{{UP}}<',
'>{{DOWN}}<',
'>{{ - go up/down in the list of notes}}<',
'>{{LEFT}}<',
'>{{RIGHT}}<',
'>{{ - collapse/expand node}}<',
# shortcuts placeholder string. DO NOT MODIFY!
# 这个 not set 是快捷键占位符, 千万别改!
# '>not set<',
'>{{ - go back / forwards in the history}}<',
'>{{ - show }}<',
'>{{"Jump to" dialog}}<',
'>{{ - scroll to active note}}<',
'>{{Backspace}}<',
'>{{ - jump to parent note}}<',
'>{{ - collapse whole note tree}}<',
'>{{ - collapse sub-tree}}<',
'>{{Tab shortcuts}}<',
'>{{CTRL+click}}<',
'>{{ (or middle mouse click) on note link opens note in a new tab}}<',
'>{{ open empty tab}}<',
'>{{ close active tab}}<',
'>{{ activate next tab}}<',
'>{{ activate previous tab}}<',
'>{{Creating notes}}<',
'>{{ - create new note after the active note}}<',
'>{{ - create new sub-note into active note}}<',
'>{{Moving / cloning notes}}<',
'>{{ - move note up/down in the note list}}<',
'>{{ - move note up in the hierarchy}}<',
'>{{ - multi-select note above/below}}<',
'>{{ - select all notes in the current level}}<',
'>{{Shift+click}}<',
'>{{ - select note}}<',
'>{{ - copy active note (or current selection) into clipboard (used for }}<',
'>{{cloning}}<',
'>{{ - cut current (or current selection) note into clipboard (used for moving notes)}}<',
'>{{ - paste note(s) as sub-note into active note (which is either move or clone depending on whether it was copied or cut into clipboard)}}<',
'>{{ - delete note / sub-tree}}<',
'>{{Editing notes}}<',
'>{{ will switch back from editor to tree pane.}}<',
'>{{Ctrl+K}}<',
'>{{ - create / edit external link}}<',
'>{{ - create internal link}}<',
'>{{ - follow link under cursor}}<',
'>{{ - insert current date and time at caret position}}<',
'>{{ - jump away to the tree pane and scroll to active note}}<',
'>{{Markdown-like autoformatting}}<',
'>{{ etc. followed by space for headings}}<',
'>{{ or }}<',
'>{{ followed by space for bullet list}}<',
'>{{ followed by space for numbered list}}<',
'>{{start a line with }}<',
'>{{ followed by space for block quote}}<',
'>{{Troubleshooting}}<',
'>{{ - reload Trilium frontend}}<',
'>{{ - show developer tools}}<',
'>{{ - show SQL console}}<',
'>{{Other}}<',
'>{{ - Zen mode - display only note editor, everything else is hidden}}<',
'>{{ - focus on quick search input}}<',
'>{{ - in page search}}<',
'- {{edit <a class="external" href="https://github.com/zadam/trilium/wiki/Tree concepts#prefix">prefix</a> of active note clone}}<',
'{{Only in desktop (electron build)}}:',
'{{in tree pane will switch from tree pane into note title. Enter from note title will switch focus to text editor.}}',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/import.js'
translation = [
'>{{Import into note}}<',
'>{{Choose import file}}<',
'>{{Content of the selected file(s) will be imported as child note(s) into }}<',
'>{{Options:}}<',
'>{{Safe import}}<',
'>{{Read contents of <code>.zip</code>, <code>.enex</code> and <code>.opml</code> archives.}}<',
'>{{If you check this option, Trilium will attempt to shrink the imported images by scaling and optimization which may affect the perceived image quality. If unchecked, images will be imported without changes.}}<',
">{{This doesn't apply to }}<",
'>{{ imports with metadata since it is assumed these files are already optimized.}}<',
'>{{Shrink images}}<',
"{{Import HTML, Markdown and TXT as text notes if it's unclear from metadata}}",
"> {{Import recognized code files (e.g. <code>.json</code>) as code notes if it's unclear from metadata}}",
'>{{Import}}<',
'title="{{Trilium <code>.zip</code> export files can contain executable scripts which may contain harmful behavior. Safe import will deactivate automatic execution of all imported scripts. Uncheck "Safe import" only if the imported tar archive is supposed to contain executable scripts and you completely trust the contents of the import file.}}"',
'title="{{If this is checked then Trilium will read <code>.zip</code>, <code>.enex</code> and <code>.opml</code> files and create notes from files insides those archives. If unchecked, then Trilium will attach the archives themselves to the note.}}"',
'''title="{{<p>If you check this option, Trilium will attempt to shrink the imported images by scaling and optimization which may affect the perceived image quality. If unchecked, images will be imported without changes.</p><p>This doesn't apply to <code>.zip</code> imports with metadata since it is assumed these files are already optimized.</p>}}"''',
'''{{Replace underscores with spaces in imported note names}}''',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/include_note.js'
translation = [
'>{{Include note}}<',
'>{{Note}}<',
'>{{Include note }}<',
'>{{enter}}<',
'{{search for note by its name}}',
' logError("{{No noteId to include.}}"',
'{{Box size of the included note:}}',
'{{small (~ 10 lines)}}',
'{{medium (~ 30 lines)}}',
'{{full (box shows complete text)}}',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/info.js'
translation = [
'>{{Info message}}<',
'>{{OK}}<',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/jump_to_note.js'
translation = [
'>{{Jump to note}}<',
'>{{Note}}<',
'>{{Search in full text }}<',
'>{{Ctrl+Enter}}<',
'{{search for note by its name}}',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/markdown_import.js'
translation = [
'>{{Markdown import}}<',
">{{Because of browser sandbox it's not possible to directly read clipboard from JavaScript. Please paste the Markdown to import to textarea below and click on Import button}}<",
'>{{Import }}<',
'>{{Ctrl+Enter}}<',
'showMessage("{{Markdown content has been imported into the document.}}"',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/move_to.js'
translation = [
'>{{Move notes to ...}}<',
'>{{Notes to move}}<',
' {{Target parent note}}',
'>{{Move to selected note }}<',
'>{{enter}}<',
'{{search for note by its name}}',
'showMessage({{`Selected notes have been moved into ${parentNote.title}`}}',
' logError("{{No path to move to.}}"',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/revisions.js'
translation = [
'>{{Note revisions}}<',
'>{{Delete all revisions}}<',
'>{{Dropdown trigger}}<',
'title="{{Delete all revisions of this note}}"',
'title="{{Help on Note revisions}}"',
'>{{Restore this revision}}<',
'>{{Delete this revision}}<',
'>{{Download}}<',
'{{This revision was last edited on}} ',
'{{Do you want to restore this revision? This will overwrite current title/content of the note with this revision.}}',
'{{Do you want to delete this revision? This action will delete revision title and content, but still preserve revision metadata.}}',
"{{Preview isn't available for this note type.}}",
'{{Do you want to delete all revisions of this note? This action will erase revision title and content, but still preserve revision metadata.}}',
"showMessage('{{Note revision has been restored.}}'",
"showMessage('{{Note revision has been deleted.}}'",
"showMessage('{{Note revisions has been deleted.}}'",
'"{{No revisions for this note yet...}}"',
'.text("{{File size:}}")',
'.text("{{Preview}}:")',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/note_type_chooser.js'
translation = [
'>{{Choose note type}}<',
'{{Choose note type / template of the new note:}}',
'>{{Dropdown trigger}}<',
]
replace_in_file(file_path, translation)
# Removed in 0.58.2
# file_path = 'src/public/app/widgets/dialogs/options.js'
# translation = [
# '>{{Options}}<',
# '>{{Appearance}}<',
# '>{{Shortcuts}}<',
# '>{{Keyboard shortcuts}}<',
# '>{{Text notes}}<',
# '>{{Code notes}}<',
# # removed from 0.50
# # '>{{Username & password}}<',
# '>{{Password}}<',
# '>{{ETAPI}}<',
# '>{{Backup}}<',
# '>{{Sync}}<',
# '>{{Other}}<',
# '>{{Advanced}}<',
# ]
# replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/password_not_set.js'
translation = [
'>{{Password is not set}}<',
'{{Protected notes are encrypted using a user password, but password has not been set yet.}}',
'''{{To be able to protect notes, <a class="open-password-options-button" href="javascript:">\n click here to open the Options dialog</a> and set your password.}}''',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/prompt.js'
translation = [
'>{{Prompt}}<',
'>{{OK }}<',
'>{{enter}}<',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/protected_session_password.js'
translation = [
'>{{Protected session}}<',
'{{To proceed with requested action you need to start protected session by entering password:}}',
'>{{Start protected session }}<',
'>{{enter}}<',
'title="{{Help on Protected notes}}"',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/recent_changes.js'
translation = [
'>{{Recent changes}}<',
'{{Erase deleted notes now}}',
'showMessage("{{Deleted notes have been erased.}}"',
'{{No changes yet ...}}',
'{{Do you want to undelete this note and its sub-notes?}}',
'text("{{undelete}}")',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/sort_child_notes.js'
translation = [
'>{{Sort children by ...}}<',
'>{{Sorting criteria}}<',
'>{{Sorting direction}}<',
'>{{Folders}}<',
'>{{Natural Sort}}<',
'>{{Sort }}<',
'>{{enter}}<',
' {{title}}',
' {{date created}}',
' {{date modified}}',
' {{ascending}}',
' {{descending}}',
' {{sort folders at the top}}',
'{{sort with respect to different character sorting and collation rules in different languages or regions.}}',
'{{Natural sort language}}',
'{{The language code for natural sort, e.g. "zh-CN" for Chinese.}}',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/dialogs/upload_attachments.js'
translation = [
'>{{Upload attachments to note}}<',
'>{{Choose files}}<',
'>{{Files will be uploaded as attachments into }}<',
'>{{Options:}}<',
'>{{If you check this option, Trilium will attempt to shrink the uploaded images by scaling and optimization which may affect the perceived image quality. If unchecked, images will be uploaded without changes.}}<',
'>{{Shrink images}}<',
'>{{Upload}}<',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/advanced/consistency_checks.js'
translation = [
'>{{Consistency Checks}}<',
'>{{Find and fix consistency issues}}<',
'showMessage("{{Finding and fixing consistency issues...}}"',
'showMessage("{{Consistency issues should be fixed.}}"',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/advanced/database_anonymization.js'
translation = [
'>{{Database Anonymization}}<',
'>{{Full Anonymization}}<',
'>{{Save fully anonymized database}}<',
'>{{Light Anonymization}}<',
'>{{Existing anonymized databases}}<',
'{{This action will create a new copy of the database and anonymize it (remove all note content and leave only structure and some non-sensitive metadata)\n for sharing online for debugging purposes without fear of leaking your personal data.}}',
'>{{This action will create a new copy of the database and do a light anonymization on it — specifically only content of all notes will be removed, but titles and attributes will remain. Additionally, custom JS frontend/backend script notes and custom widgets will remain. This provides more context to debug the issues.}}<',
'>{{You can decide yourself if you want to provide a fully or lightly anonymized database. Even fully anonymized DB is very useful, however in some cases lightly anonymized database can speed up the process of bug identification and fixing.}}<',
'>{{Save lightly anonymized database}}<',
'showMessage({{`Created fully anonymized database in ${resp.anonymizedFilePath}`}}',
'showMessage({{`Created lightly anonymized database in ${resp.anonymizedFilePath}`}}',
'showMessage("{{Creating fully anonymized database...}}"',
'showMessage("{{Creating lightly anonymized database...}}"',
'showError("{{Could not create anonymized database, check backend logs for details}}"',
'"{{no anonymized database yet}}"',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/advanced/database_integrity_check.js'
translation = [
'>{{Database Integrity Check}}<',
'>{{This will check that the database is not corrupted on the SQLite level. It might take some time, depending on the DB size.}}<',
'>{{Check database integrity}}<',
'showMessage(`{{Integrity check failed:}}',
'showMessage("{{Checking database integrity...}}"',
'showMessage("{{Integrity check succeeded - no problems found.}}"',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/advanced/sync.js'
translation = [
'>{{Sync}}<',
'>{{Force full sync}}<',
'>{{Fill entity changes records}}<',
'showMessage("{{Full sync triggered}}"',
'showMessage("{{Filling entity changes rows...}}"',
'showMessage("{{Sync rows filled successfully}}"',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/advanced/vacuum_database.js'
translation = [
'>{{Vacuum Database}}<',
'>{{Vacuum database}}<',
'>{{This will rebuild the database which will typically result in a smaller database file. No data will be actually changed.}}<',
'showMessage("{{Vacuuming database...}}"',
'showMessage("{{Database has been vacuumed}}"',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/appearance/fonts.js'
translation = [
'>{{Fonts}}<',
'>{{Main Font}}<',
'>{{Font family}}<',
'>{{Size}}<',
'>{{Note Tree Font}}<',
'>{{Note Detail Font}}<',
'>{{Monospace (code) Font}}<',
'>{{Note that tree and detail font sizing is relative to the main font size setting.}}<',
'>{{Not all listed fonts may be available on your system.}}<',
'>{{reload frontend}}<',
'{{To apply font changes, click on}}',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/appearance/max_content_width.js'
translation = [
'>{{Content Width}}<',
'>{{Trilium by default limits max content width to improve readability for maximized screens on wide screens.}}<',
'>{{Max content width in pixels}}<',
'>{{reload frontend}}<',
'{{To apply content width changes, click on}}',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/appearance/native_title_bar.js'
translation = [
'>{{Native Title Bar (requires app restart)}}<',
'>{{enabled}}<',
'>{{disabled}}<',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/appearance/ribbon.js'
translation = [
'>{{Ribbon widgets}}<',
'{{Promoted Attributes ribbon tab will automatically open if promoted attributes are present on the note}}',
'{{Edited Notes ribbon tab will automatically open on day notes}}',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/appearance/theme.js'
translation = [
'>{{Theme}}<',
'>{{Override theme fonts}}<',
"title: '{{Light}}",
"title: '{{Dark}}",
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/appearance/zoom_factor.js'
translation = [
'>{{Zoom Factor (desktop build only)}}<',
'>{{Zooming can be controlled with CTRL+- and CTRL+= shortcuts as well.}}<',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/backup.js'
translation = [
'return "{{Backup}}"',
'>{{Automatic backup}}<',
'>{{Trilium can back up the database automatically:}}<',
' {{Enable daily backup}}',
' {{Enable weekly backup}}',
' {{Enable monthly backup}}',
'''>{{It's recommended to keep the backup turned on, but this can make application startup slow with large databases and/or slow storage devices.}}<''',
'>{{Backup now}}<',
'>{{Backup database now}}<',
'showMessage(`{{Database has been backed up to }}',
'showMessage("{{Options changed have been saved.}}"',
'>{{Existing backups}}<',
'"{{no backup yet}}"',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/code_notes/code_auto_read_only_size.js'
translation = [
'>{{Automatic Read-Only Size}}<',
'>{{Automatic read-only note size is the size after which notes will be displayed in a read-only mode (for performance reasons).}}<',
'>{{Automatic read-only size (code notes)}}<',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/code_notes/code_mime_types.js'
translation = [
'>{{Available MIME types in the dropdown}}<',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/code_notes/vim_key_bindings.js'
translation = [
'>{{Use vim keybindings in code notes (no ex mode)}}<',
'{{Enable Vim Keybindings}}',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/code_notes/wrap_lines.js'
translation = [
'>{{Wrap lines in code notes}}<',
'{{Enable Line Wrap (change might need a frontend reload to take effect)}}',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/etapi.js'
translation = [
'{{ETAPI is a REST API used to access Trilium instance programmatically, without UI.}}',
"""{{See more details on <a href="https://github.com/zadam/trilium/wiki/ETAPI">wiki</a> and <a onclick="window.open('etapi/etapi.openapi.yaml')" href="etapi/etapi.openapi.yaml">ETAPI OpenAPI spec</a>.}}""",
'>{{Create new ETAPI token}}<',
'>{{Existing tokens}}<',
'>{{There are no tokens yet. Click on the button above to create one.}}<',
'>{{Token name}}<',
'>{{Created}}<',
'>{{Actions}}<',
'title: "{{New ETAPI token}}"',
'title: "{{ETAPI token created}}"',
'{{Copy the created token into clipboard. Trilium stores the token hashed and this is the last time you see it.}}',
'title: "{{Rename token}}"',
'title="{{Rename this token}}"',
'title="{{Delete / deactive this token}}"',
'''message: "{{Please enter new token's name}}"''',
'''defaultValue: "{{new token}}"''',
''' alert("{{Token name can't be empty}}"''',
'{{Are you sure you want to delete ETAPI token}}',
'title="{{Delete / deactivate this token}}"',
'''showError("{{Token name can't be empty}}"''',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/images/images.js'
translation = [
'>{{Images}}<',
'{{Download images automatically for offline use.}}',
'>{{(pasted HTML can contain references to online images, Trilium will find those references and download the images so that they are available offline)}}<',
'{{Enable image compression}}',
'>{{Max width / height of an image in pixels (image will be resized if it exceeds this setting).}}<',
'>{{JPEG quality (10 - worst quality, 100 best quality, 50 - 85 is recommended)}}<',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/options_widget.js'
translation = [
'title: "{{Options status}}"',
'message: "{{Options change have been saved.}}"',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/other/attachment_erasure_timeout.js'
translation = [
'>{{Attachment Erasure Timeout}}<',
'{{Attachments get automatically deleted (and erased) if they are not referenced by their note anymore after a defined time out.}}',
'{{Erase attachments after X seconds of not being used in its note}}',
'{{You can also trigger erasing manually (without considering the timeout defined above)}}',
'{{Erase unused attachment notes now}}',
'showMessage("{{Unused attachments have been erased.}}"',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/other/network_connections.js'
translation = [
'>{{Network Connections}}<',
'{{Check for updates automatically}}',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/other/note_erasure_timeout.js'
translation = [
'>{{Note Erasure Timeout}}<',
'>{{Erase notes after X seconds}}<',
'>{{You can also trigger erasing manually:}}<',
'>{{Erase deleted notes now}}<',
'showMessage("{{Deleted notes have been erased.}}"',
'{{Deleted notes (and attributes, revisions...) are at first only marked as deleted and it is possible to recover them \n from Recent Notes dialog. After a period of time, deleted notes are "erased" which means \n their content is not recoverable anymore. This setting allows you to configure the length \n of the period between deleting and erasing the note.}}',
'{{You can also trigger erasing manually (without considering the timeout defined above)}}',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/other/revisions_snapshot_interval.js'
translation = [
'>{{Note Revisions Snapshot Interval}}<',
'>{{Note revision snapshot time interval is time in seconds after which a new note revision will be created for the note. See }}<',
'>{{wiki}}<',
'> {{for more info.}}<',
'>{{Note revision snapshot time interval (in seconds)}}<',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/other/search_engine.js'
translation = [
'>{{Search Engine}}<',
'>{{Custom search engine requires both a name and a URL to be set. If either of these is not set, DuckDuckGo will be used as the default search engine.}}<',
'>{{Predefined search engine templates}}<',
'>{{Bing}}<',
'>{{Baidu}}<',
'>{{Duckduckgo}}<',
'>{{Google}}<',
'>{{Custom search engine name}}<',
'>{{Custom search engine URL should include <code>{keyword}</code> as a placeholder for the search term.}}<',
'>{{Save}}<',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/other/tray.js'
translation = [
'>{{Tray}}<',
'{{Enable tray (Trilium needs to be restarted for this change to take effect)}}',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/password.js'
translation = [
'return "{{Password}}"',
'>{{click here to reset it}}<',
'>{{Old password}}<',
'>{{New password}}<',
'>{{New password confirmation}}<',
'>{{Change password}}<',
' alert("{{Password has been reset. Please set new password}}"',
' alert("{{New passwords are not the same.}}"',
' alert("{{Password has been changed. Trilium will be reloaded after you press OK.}}"',
'{{Please take care to remember your new password. Password is used for logging into the web interface and\n to encrypt protected notes.}}',
'{{If you forget your password, then all your protected notes are forever lost.}}',
'{{In case you did forget your password}}',
'"{{By resetting the password you will forever lose access to all your existing protected notes. Do you really want to reset the password?}}"',
"'{{Change Password}}' : '{{Set Password}}')",
'>{{Protected Session Timeout}}<',
"{{Protected session timeout is a time period after which the protected session is wiped from\n the browser's memory. This is measured from the last interaction with protected notes. See}}",
'{{for more info.}}',
'>{{Protected session timeout (in seconds)}}<',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/shortcuts.js'
translation = [
'return "{{Shortcuts}}"',
'>{{Keyboard Shortcuts}}<',
'{{Multiple shortcuts for the same action can be separated by comma.}}',
'{{See <a href="https://www.electronjs.org/docs/latest/api/accelerator">Electron documentation</a> for available modifiers and key codes.}}',
'>{{Action name}}<',
'>{{Shortcuts}}<',
'>{{Default shortcuts}}<',
'>{{Description}}<',
'>{{Reload app to apply changes}}<',
'>{{Set all shortcuts to the default}}<',
'{{Do you really want to reset all keyboard shortcuts to the default?}}',
'{{Type text to filter shortcuts...}}',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/spellcheck.js'
translation = [
'return "{{Spellcheck}}"',
'>{{Spell Check}}<',
'>{{These options apply only for desktop builds, browsers will use their own native spell check. App restart is required after change.}}<',
'{{Enable spellcheck}}',
'>{{Language code(s)}}<',
'>{{Multiple languages can be separated by comma, e.g. }}<',
'>{{Available language codes: }}<',
'>. {{Changes to the spell check options will take effect after application restart.}}<',
]
replace_in_file(file_path, translation)
file_path = 'src/public/app/widgets/type_widgets/options/sync.js'
translation = [
'return "{{Sync}}"',
'>{{Sync Configuration}}<',
'>{{Server instance address}}<',
'>{{Sync timeout (milliseconds)}}<',
'>{{Sync proxy server (optional)}}<',
'>{{Note:}}<',