Avatar for MaBe

MaBe

Member since Nov 2015 • Last active Feb 2020

No matter what device you use, with Espruino you always have a lot of fun.

Special thanks goes to Gordon.

Most recent activity

  • in Bangle.js
    Avatar for MaBe

    perfect 👍🏻

  • in Bangle.js
    Avatar for MaBe

    Use Bangle.js https://banglejs.com/apps/

    • Tab About and
    • Set Bangle.JS Time to fix the GPS stuff.
    • use longpress BTN3 to reset

    Can you connect via WebIDE and share some details like process.env

    >process.env
    ={
      VERSION: "2v04.356",
      GIT_COMMIT: "3bd026c23",
      BOARD: "BANGLEJS",
      FLASH: 524288, SPIFLASH: 4194304, STORAGE: 1048576, RAM: 65536,
      SERIAL: "c7fa9624-75c07c51",
      CONSOLE: "Bluetooth",
      MODULES: "Flash,Storage,hea" ... "ow,graphical_menu",
      EXPTR: 536883676 }
    > 
    
  • in ESP32
    • 22 comments
    • 4,031 views
  • in JavaScript
    Avatar for MaBe

    Using glibc export for an example how locale could look

    So this peace of code is not a app but a locale saver

    • lives in Bangle.js App config page
    • User select his locale from a pull down
    • only store selected local in @locale
    • app can use it via reading @locale

    What do you think?

    var locales = {
        "en_US" : {
            mon   : "January,February,March,April,May,June,J­uly,August,September,October,November,De­cember",
            abmon : "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct­,Nov,Dec",
            day   : "Sunday,Monday,Tuesday,Wednesday,Thursda­y,Friday,Saturday",
            abday : "Sun,Mon,Tue,Wed,Thu,Fri,Sat"
        },
    
        "de_DE" : {
            mon   : "Januar,Februar,März,April,Mai,Juni,Juli­,August,September,Oktober,November,Dezem­ber",
            abmon : "Jan,Feb,Mär,Apr,Mai,Jun,Jul,Aug,Sep,Okt­,Nov,Dez",
            day   : "Sonntag,Montag,Dienstag,Mittwoch,Donner­stag,Freitag,Samstag",
            abday : "So,Mo,Di,Mi,Do,Fr,Sa"
        },
        "fr_FR": {
            mon   : "janvier,février,mars,avril,mai,juin,jui­llet,août,septembre,octobre,novembre,déc­embre",
            abmon : "anv.,févr.,mars,avril,mai,juin,juil.,ao­ût,sept.,oct.,nov.,déc.",
            day   : "dimanche,lundi,mardi,mercredi,jeudi,ven­dredi,samedi",
            abday : "dim.,lun.,mar.,mer.,jeu.,ven.sam."
        },
        "it_IT": {
            mon   : "gennaio,febbraio,marzo,aprile,maggio,gi­ugno,luglio,agosto,settembre,ottobre,nov­embre,dicembre",
            abmon : "gen,feb,mar,apr,mag,giu,lug,ago,set,ott­,nov,dic",
            day   : "domenica,lunedì,martedì,mercoledì,giove­dì,venerdì, sabato",
            abday : "dom,lun,mar,mer,gio,ven,sab"
        }
    };
    
    
    // save my relevant locale setting for for day, abday, mon, abmon
    var locale = "en_US";
    require("Storage").write("@locale",JSON.­stringify(locales[locale]));
    
    // read my locale setting for day, abday, mon, abmon
    myLocale = require("Storage").readJSON("@locale");
    //
    console.log(myLocale.day.split(','));
    console.log(myLocale.abday.split(','));
    console.log(myLocale.mon.split(','));
    console.log(myLocale.abmon.split(','));
    
    // output
    
    >[
      "Sunday",
      "Monday",
      "Tuesday",
      "Wednesday",
      "Thursday",
      "Friday",
      "Saturday"
     ]
    [
      "Sun",
      "Mon",
      "Tue",
      "Wed",
      "Thu",
      "Fri",
      "Sat"
     ]
    [
      "January",
      "February",
      "March",
      "April",
      "May",
      "June",
      "July",
      "August",
      "September",
      "October",
      "November",
      "December"
     ]
    [
      "Jan",
      "Feb",
      "Mar",
      "Apr",
      "May",
      "Jun",
      "Jul",
      "Aug",
      "Sep",
      "Oct",
      "Nov",
      "Dec"
     ]
    > 
    
    
  • in JavaScript
    Avatar for MaBe

    https://lh.2xlibre.net/locale/de_DE/

    LC_TIME entries can be used and find via de_DE or any other language

    Edit: We can use the glibc export as base to create a subset.

  • in JavaScript
    Avatar for MaBe

    What about custom fonts, is there a possibility to scale them with using g.setFont("Name",scaleFactor)?

  • in JavaScript
    Avatar for MaBe

    I agree, have you checked Intl.DateTimeFormat - post #15

    did you intentionally use Maerz vs März?

    Yes, just 7 bit, that’s the next issue to handle.

    Edit: We can use the font tested here ;-)

  • in JavaScript
    Avatar for MaBe

    Great, thanks for sharing.

    I will use this to build a class with using ds and ms from @locale.

    store the county specific locale for day and month, eg de-DE

        var loc = { 
            "ds" : "So,Mo,Di,Mi,Do,Fr,Sa",
            "ms":"Jan,Feb,Maerz,Apr,Mai,Jun,Jul,Aug,­Sept,Okt,Nov,Dez" 
        };
        require("Storage").write("@locale",JSON.­stringify(loc));
    

    and than use it to init the DF class

    class DF {
             constructor(ds, ms) {
                 this.ds = ds;
                 this.ms = ms;
             }
             f() { ......}
             ....
             i()  {.....}
    }
    
    loc = require("Storage").read("@locale");
    df = new DF( loc.ds, loc.ms);
    
    

    or something similar ;-)

  • in JavaScript
    Avatar for MaBe

    Possible applications use for Bangle.js clocks with date.

    Like to continue this discussion , because there will be requests for something like

    Looking at the MDN docs there's a standard for Intl (https://developer.mozilla.org/en-US/docs­/Web/JavaScript/Reference/Global_Objects­/DateTimeFormat) that I reckon could be implemented as a JS library reasonably easily?

    named in https://github.com/espruino/Espruino/iss­ues/1703

    What about extend "DateFormatter" to pass names for your local days and month so it’s not blowing up the module.

    eg days and mons as long and/or short format

    days: "SundayMondayTuesdayWednesday...", dayLen: 9 and equally for mons: "JanuaryFeburary_...", monLen: 9)

    To make a clock app very flexible, same code for all locales.
    it could be injected via app customized page eg Route Viewer

    What do you think about this idea?

Actions