• App Loader offers an app called Languages. This is customizable and gives you the choice to upload country specific settings, which are called locales. Take a look at local planet page eg en_GB

    By customizing means: Select a locale like de_DE and click on Upload. Now you have stored the information on your Bangle.js.

    Keep in mind that only the 6x8 font can handle char values > 127.

    The app Settings is using this locale to translate some words into you language , see attached pictures.

    Existing translation set:

    trans: { yes: "ja", Yes: "Ja", no: "nein", No: "Nein", ok: "ok", on: "an", off: "aus" }}
    

    That allows to display Yes as meaning in you local like Ja and so on.

    Code snippet

    var locale = require('locale');
    console.log(locale.translate("Yes"));
    Ja
    

    Or get the day and month name in the local language

            abmonth: "Jan,Feb,Mär,Apr,Mai,Jun,Jul,Aug,Sep,Okt,Nov,Dez",
            month: "Januar,Februar,März,April,Mai,Juni,Juli,August,September,Oktober,November,Dezember",
            abday: "So,Mo,Di,Mi,Do,Fr,Sa",
            day: "Sonntag,Montag,Dienstag,Mittwoch,Donnerstag,Freitag,Samstag",
    

    Code snippet

    var locale = require('locale');
    //  day of  week for today 
            // normal
            console.log(locale.dow(new Date())); 
            // Mittwoch
            // short
            console.log(locale.dow(new Date(), 1)); 
            // Mi
    
    // name of month for today  
            // normal
           console.log(locale.month(new Date()));
           // März
           // short 
           console.log(locale.month(new Date(), 1));
           // Mär
    

    Snippet with all possible function for locale

    var locale = require('locale');
    
    console.log(locale.name);
    console.log(locale.currencySym);
    console.log(locale.dow(new Date()));
    console.log(locale.dow(new Date(), 1));
    console.log(locale.month(new Date()));
    console.log(locale.month(new Date(), 1));
    console.log(locale.number(4.98));
    console.log(locale.currency(4.98));
    console.log(locale.distance(150));
    console.log(locale.distance(15000));
    console.log(locale.speed(150));
    console.log(locale.temp(150));
    console.log(locale.translate("off"));
    console.log(locale.date(new Date()));
    console.log(locale.date(new Date(),1));
    console.log(locale.time(new Date()));
    console.log(locale.time(new Date(),1));
    
    /* output
    de_DE
    Mittwoch
    Mi
    März
    Mär
    4,98
    4,98€
    150m
    15km
    150kmh
    150°C
    aus
    Mittwoch, 25. März 2020
    25.03.2020
    08:11:09
    08:11
    */
    

    Hope you now have an idea what this app can be used for and you start adding locales to your apps.

    If your language is missing or has typos, please create issues or pull request on github.


    2 Attachments

    • Setting_Sample.jpg
    • Setting_without.jpg
  • Is it possible to render UTF-8 characters (Kanji)?

  • Not sure, but you can try to build a Kanji bitmap font, check section custom-fonts.

  • Is it possible to render UTF-8 characters (Kanji)?

    Right now you only have native support for simple 8 bit character encoding, and that's handled in the 6x8 font as ISO10646-1 (chars 0-255 of UTF-16) - Vector and 4x6 fonts use just ASCII (chats 0-127).

    Unfortunately the limit is really the amount of memory available - there just isn't the flash to build in >256 chars of fonts.

    The simplest way would be to create your own font that used an 8 bit Japanese codepage too, like https://en.wikipedia.org/wiki/JIS_X_0201 - but it sounds like that's not really complex enough for modern use.

    But... Nothing actually stops you from storing a proper (>8 bit) character map in flash and rendering from there with g.drawImage - you could then write your own drawString implementation that would work with UTF-8.

    It depends what you're after though - if you're trying to render text that comes from a phone or PC it's probably much easier and better (maybe even antialiased) to render on the host device and send a bitmap over.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

What does the Languages app and how can it be used in apps.

Posted by Avatar for MaBe @MaBe

Actions