Changeset 35953 for main/trunk


Ignore:
Timestamp:
2022-01-11T11:10:56+13:00 (2 years ago)
Author:
cstephen
Message:

Default spellcheck on when mi lang is present

Location:
main/trunk/model-interfaces-dev/atea/macron-restoration/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/atea/macron-restoration/src/components/DirectInput.vue

    r35951 r35953  
    22import { mapState } from "vuex";
    33import { saveAs } from "file-saver"
    4 import { log } from "../js/Util"
     4import Util, { log } from "../js/Util"
    55import MacronRestorationModule from "../js/MacronRestorationModule"
    66import { SnackController } from "./Snackbar.vue"
     
    172172        // The null check is used to default this setting to true
    173173        this.preserveExistingMacrons = (localStorage.getItem("preserveExistingMacrons") ?? "true") === "true";
    174         this.enableSpellcheck = localStorage.getItem("enableSpellcheck") === "true";
    175174        this.showMacronisedWords = (localStorage.getItem("showMacronisedWords") ?? "true") === "true";
    176175        this.normaliseLinebreaks = localStorage.getItem("normaliseLinebreaks") === "true";
     176
     177        const enableSpellcheck = localStorage.getItem("enableSpellcheck");
     178        if (enableSpellcheck) {
     179            this.enableSpellcheck = enableSpellcheck === "true";
     180        }
     181        else {
     182            this.enableSpellcheck = Util.getNavigatorLanguage().startsWith("mi");
     183        }
    177184    }
    178185}
  • main/trunk/model-interfaces-dev/atea/macron-restoration/src/js/Util.js

    r35714 r35953  
    6868            this.lut[d3 & 0xff] + this.lut[d3 >> 8 & 0xff] + this.lut[d3 >> 16 & 0xff] + this.lut[d3 >> 24 & 0xff];
    6969    }
     70
     71    /**
     72     * Gets the navigator's primary language.
     73     * @returns {String} The primary language code.
     74     */
     75    static getNavigatorLanguage() {
     76        if (navigator.languages && navigator.languages.length) {
     77            return navigator.languages[0];
     78        }
     79
     80        if (navigator.language) {
     81            return navigator.language;
     82        }
     83
     84        // IE Support
     85        return navigator.browserLanguage || navigator.systemLanguage || navigator.userLanguage;
     86    }
    7087}
Note: See TracChangeset for help on using the changeset viewer.