Skip to content

Commit b22d750

Browse files
Language updates & fixes
- Removed a few problematic language dictionaries. Some of them straight up didn't exist and others would freeze the app forever. - Added a loading popup for when dictionaries are loading. - Add dictionaries to local instead of loading from the server. - Updated nspell - Renamed Preferred Langauge to Spell Check Language & moved to underneath Spell Check option.
1 parent 6688dda commit b22d750

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3176748
-57
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"knockout": "^3.5.0",
4141
"knockout-ace": "^1.0.1",
4242
"lightweight-emoji-picker": "0.0.2",
43-
"nspell": "^2.1.2",
43+
"nspell": "^2.1.5",
4444
"spectrum-colorpicker": "^1.8.0",
4545
"spoken": "^1.1.17",
4646
"sweetalert2": "^9.10.13",

src/index.html

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -401,18 +401,6 @@
401401
<h3>Preferences</h3>
402402
<div class="settings-row">
403403
<div class="settings-column">
404-
<!-- Language -->
405-
<div class="settings-item">
406-
<label class="settings-label" for="language">Preferred Language</label>
407-
<select id="language" class="settings-value" data-bind="
408-
options: app.ui.availableLanguages,
409-
optionsText: 'name',
410-
optionsValue: 'id',
411-
value: app.settings.language,
412-
event: { change: app.setLanguage }">
413-
</select>
414-
</div>
415-
416404
<!-- Theme -->
417405
<div class="settings-item">
418406
<label class="settings-label" for="theme">Theme</label>
@@ -505,6 +493,18 @@ <h3>Preferences</h3>
505493
<input id="spellcheck" type="checkbox" data-bind="checked: app.settings.spellcheckEnabled">
506494
</div>
507495

496+
<!-- Language -->
497+
<div class="settings-item">
498+
<label class="settings-label" for="language"><svg class="icon icon-language icon-fw icon-lg settings-icon"><use xlink:href="public/icons.svg#icon-language"></use></svg> Spell Check Language</label>
499+
<select id="language" class="settings-value" data-bind="
500+
options: app.ui.availableLanguages,
501+
optionsText: 'name',
502+
optionsValue: 'id',
503+
value: app.settings.language,
504+
event: { change: app.setLanguage }">
505+
</select>
506+
</div>
507+
508508
<!-- Autocomplete Suggestions -->
509509
<div class="settings-item">
510510
<label class="settings-label" for="autocompleteSuggestions"><svg class="icon icon-comment icon-fw icon-lg settings-icon"><use xlink:href="public/icons.svg#icon-comment"></use></svg> Autocompletion Suggestions</label>

src/js/classes/app.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ export var App = function(name, version) {
223223

224224
self.settings.apply();
225225

226+
// Load Language
227+
setTimeout(() => {
228+
self.setLanguage(self.settings.language());
229+
}, 250);
230+
226231
// search field enter
227232
$('.search-title input').click(self.updateSearch);
228233
$('.search-body input').click(self.updateSearch);

src/js/classes/ui.js

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,38 +48,23 @@ export const UI = function(app) {
4848

4949
// Language selector --------------------------------------------------------
5050
this.availableLanguages = [
51-
{ name: 'Afrikaans', id: 'af-ZA' },
52-
{ name: 'Bahasa Indonesia', id: 'id-ID' },
53-
{ name: 'Bahasa Melayu', id: 'ms-MY' },
54-
{ name: 'Català', id: 'ca-ES' },
5551
{ name: 'Čeština', id: 'cs-CZ' },
5652
{ name: 'Deutsch', id: 'de-DE' },
5753
{ name: 'English', id: 'en-GB' },
5854
{ name: 'Español', id: 'es-ES' },
59-
{ name: 'Euskara', id: 'eu-ES' },
6055
{ name: 'Français', id: 'fr-FR' },
61-
{ name: 'Galego', id: 'gl-ES' },
62-
{ name: 'Hrvatski', id: 'hr_HR' },
63-
{ name: 'IsiZulu', id: 'zu-ZA' },
6456
{ name: 'Íslenska', id: 'is-IS' },
65-
{ name: 'Italiano', id: 'it-IT' },
66-
{ name: 'Magyar', id: 'hu-HU' },
6757
{ name: 'Nederlands', id: 'nl-NL' },
6858
{ name: 'Norsk bokmål', id: 'nb-NO' },
6959
{ name: 'Polski', id: 'pl-PL' },
70-
{ name: 'Português', id: 'pt-BR' },
7160
{ name: 'Română', id: 'ro-RO' },
7261
{ name: 'Slovenčina', id: 'sk-SK' },
73-
{ name: 'Suomi', id: 'fi-FI' },
7462
{ name: 'Svenska', id: 'sv-SE' },
7563
{ name: 'Türkçe', id: 'tr-TR' },
7664
{ name: 'български', id: 'bg-BG' },
7765
{ name: 'Pусский', id: 'ru-RU' },
7866
{ name: 'Српски', id: 'sr-RS' },
7967
{ name: '한국어', id: 'ko-KR' },
80-
{ name: '中文', id: 'cmn-Hans-CN' },
81-
{ name: '日本語', id: 'ja-JP' },
82-
{ name: 'Lingua latīna', id: 'la' }
8368
];
8469

8570
// Line Style selector -----------------------------------------------------------
@@ -90,6 +75,10 @@ export const UI = function(app) {
9075

9176
// openSettingsDialog
9277
this.openSettingsDialog = function() {
78+
if (app.editing() !== null) {
79+
app.closeEditor();
80+
}
81+
9382
self.settingsDialogVisible(true);
9483

9584
$('.settings-dialog')

src/js/libs/spellcheck_ace.js

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,67 @@ function load_dictionary(dicLanguage) {
3333
dicPath = utils.Utils.getPublicPath(`dictionaries/${dicLanguage}/index.dic`);
3434
affPath = utils.Utils.getPublicPath(`dictionaries/${dicLanguage}/index.aff`);
3535

36-
$.get(dicPath, function(data) {
37-
dicData = data;
38-
})
39-
.fail(function() {
40-
console.error(
41-
`${dicLanguage} not found locally. Loading dictionary from server instead...`
42-
);
43-
dicPath = `https://raw.githubusercontent.com/wooorm/dictionaries/master/dictionaries/${dicLanguage}/index.dic`;
44-
affPath = `https://raw.githubusercontent.com/wooorm/dictionaries/master/dictionaries/${dicLanguage}/index.aff`;
45-
46-
$.get(dicPath, function(data) {
47-
dicData = data;
48-
}).done(function() {
49-
$.get(affPath, function(data) {
50-
affData = data;
51-
}).done(function() {
52-
console.log('Dictionary loaded from server');
53-
dictionary = new nspell(affData, dicData);
54-
contents_modified = true;
55-
});
56-
});
36+
Swal.close();
37+
Swal.fire({
38+
title: 'Loading Language...',
39+
text: 'Please Wait',
40+
allowOutsideClick: false,
41+
allowEscapeKey: false,
42+
allowEnterKey: false,
43+
backdrop: true
44+
});
45+
Swal.showLoading();
46+
47+
setTimeout(() => {
48+
$.get(dicPath, function(data) {
49+
dicData = data;
5750
})
51+
// .fail(function() {
52+
// console.error(
53+
// `${dicLanguage} not found locally. Loading dictionary from server instead...`
54+
// );
55+
// dicPath = `https://raw.githubusercontent.com/wooorm/dictionaries/master/dictionaries/${dicLanguage}/index.dic`;
56+
// affPath = `https://raw.githubusercontent.com/wooorm/dictionaries/master/dictionaries/${dicLanguage}/index.aff`;
57+
58+
// $.get(dicPath, function(data) {
59+
// dicData = data;
60+
// }).done(function() {
61+
// Swal.fire({
62+
// title: 'Loading...',
63+
// text: 'Please Wait'
64+
// });
65+
// Swal.showLoading();
66+
// $.get(affPath, function(data) {
67+
// affData = data;
68+
// }).done(function() {
69+
// console.log('Dictionary loaded from server');
70+
// dictionary = new nspell(affData, dicData);
71+
// contents_modified = true;
72+
// app.ui.notification.fire({
73+
// title: 'Language Loaded!',
74+
// icon: 'success'
75+
// });
76+
// });
77+
// });
78+
// })
5879
.done(function() {
5980
$.get(affPath, function(data) {
6081
affData = data;
6182
}).done(function() {
62-
console.log('Dictionary loaded locally');
6383
dictionary = new nspell(affData, dicData);
84+
console.log('Dictionary loaded locally');
85+
Swal.close();
86+
app.ui.notification.fire({
87+
title: 'Language Loaded!',
88+
icon: 'success'
89+
});
6490
contents_modified = true;
91+
if (app.editing() !== null && app.settings.spellcheckEnabled()) {
92+
spell_check();
93+
}
6594
});
6695
});
96+
}, 100);
6797
}
6898
exports.load_dictionary = load_dictionary;
6999

0 commit comments

Comments
 (0)