mirror of
https://github.com/NicolasConstant/sengi
synced 2024-12-22 13:54:10 +01:00
added lang autodetect disable option
This commit is contained in:
parent
8703df27d5
commit
d7f988ecb9
@ -62,12 +62,20 @@
|
||||
<a href (click)="onRemoveLang(l)" class="form-button language__entry__action sound__play">remove</a>
|
||||
</div>
|
||||
<input type="text" (input)="onSearchLang($event.target.value)" [(ngModel)]="searchLang"
|
||||
placeholder="Find Language" autocomplete="off" class="form-control form-control-sm language__search"/>
|
||||
placeholder="Find Language" autocomplete="off"
|
||||
class="form-control form-control-sm language__search" />
|
||||
<div *ngFor="let l of searchedLangs" class="language__entry">
|
||||
<span class="language__entry__name">{{ l.name }} ({{l.iso639}})</span>
|
||||
<a href (click)="onAddLang(l)" class="form-button language__entry__action sound__play">add</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<input class="sub-section__checkbox" [(ngModel)]="disableLangAutodetectEnabled"
|
||||
(change)="onDisableLangAutodetectChanged()" type="checkbox" name="disableLangAutodetec"
|
||||
value="disableLangAutodetec" id="disableLangAutodetec">
|
||||
<label class="noselect sub-section__label" for="disableLangAutodetec">disable language autodetection</label>
|
||||
</div>
|
||||
<h4 class="panel__subtitle">Twitter Bridge</h4>
|
||||
<div class="sub-section">
|
||||
|
@ -29,6 +29,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
||||
disableRemoteStatusFetchingEnabled: boolean;
|
||||
disableAvatarNotificationsEnabled: boolean;
|
||||
disableSoundsEnabled: boolean;
|
||||
disableLangAutodetectEnabled: boolean;
|
||||
version: string;
|
||||
|
||||
hasPleromaAccount: boolean;
|
||||
@ -146,6 +147,7 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
||||
this.twitterBridgeInstance = settings.twitterBridgeInstance;
|
||||
|
||||
this.configuredLangs = this.languageService.getConfiguredLanguages();
|
||||
this.disableLangAutodetectEnabled = settings.disableLangAutodetec;
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
@ -273,6 +275,13 @@ export class SettingsComponent implements OnInit, OnDestroy {
|
||||
return false;
|
||||
}
|
||||
|
||||
onDisableLangAutodetectChanged() {
|
||||
this.notifyRestartNeeded();
|
||||
let settings = this.settingsService.getSettings();
|
||||
settings.disableLangAutodetec = this.disableLangAutodetectEnabled;
|
||||
this.settingsService.saveSettings(settings);
|
||||
}
|
||||
|
||||
onDisableAutofocusChanged() {
|
||||
this.notifyRestartNeeded();
|
||||
let settings = this.settingsService.getSettings();
|
||||
|
@ -24,26 +24,24 @@ export class LanguageService {
|
||||
this.detectedLanguage(l);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private detectedLanguage(lang: DetectedLang[]) {
|
||||
if(!lang) return;
|
||||
if (!lang) return;
|
||||
|
||||
console.warn(lang);
|
||||
|
||||
if(lang.length >= 1){
|
||||
if (lang.length >= 1) {
|
||||
const languages = this.getConfiguredLanguages();
|
||||
|
||||
let firstLang = lang[0].lang;
|
||||
let firstLocalLang = languages.find(x => x.iso639 == firstLang);
|
||||
if(firstLocalLang){
|
||||
if (firstLocalLang) {
|
||||
this.setSelectedLanguage(firstLocalLang);
|
||||
return;
|
||||
}
|
||||
|
||||
if(lang.length > 1){
|
||||
if (lang.length > 1) {
|
||||
firstLang = lang[1].lang;
|
||||
firstLocalLang = languages.find(x => x.iso639 == firstLang);
|
||||
if(firstLocalLang){
|
||||
if (firstLocalLang) {
|
||||
this.setSelectedLanguage(firstLocalLang);
|
||||
return;
|
||||
}
|
||||
@ -52,14 +50,11 @@ export class LanguageService {
|
||||
}
|
||||
|
||||
autoDetectLang(text: string): void {
|
||||
if(!text || text.length < 6) return;
|
||||
if (!text || text.length < 5) return;
|
||||
|
||||
console.warn('autodetect');
|
||||
console.warn(text);
|
||||
|
||||
//TODO: add settings to disable
|
||||
|
||||
this.electronService.detectLang(text);
|
||||
if (!this.settingsService.getSettings().disableLangAutodetec) {
|
||||
this.electronService.detectLang(text);
|
||||
}
|
||||
}
|
||||
|
||||
getSelectedLanguage(): ILanguage {
|
||||
|
@ -84,6 +84,7 @@ export class GlobalSettings {
|
||||
|
||||
configuredLanguages: ILanguage[] = [];
|
||||
selectedLanguage: ILanguage;
|
||||
disableLangAutodetec: boolean;
|
||||
}
|
||||
|
||||
export interface ILanguage {
|
||||
@ -181,6 +182,7 @@ export class SettingsState {
|
||||
newSettings.twitterBridgeInstance = oldSettings.twitterBridgeInstance;
|
||||
newSettings.configuredLanguages = oldSettings.configuredLanguages;
|
||||
newSettings.selectedLanguage = oldSettings.selectedLanguage;
|
||||
newSettings.disableLangAutodetec = oldSettings.disableLangAutodetec;
|
||||
|
||||
return newSettings;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user