Update locale comments to reflect actual espruino code
parent
0ff839bc75
commit
6af5a2cfb4
|
|
@ -30,16 +30,24 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
/*
|
/*
|
||||||
eg. the built-in en_GB is:
|
eg. the built-in en_GB at https://github.com/espruino/Espruino/blob/master/libs/js/banglejs/locale.js is:
|
||||||
|
|
||||||
exports = { name : "en_GB", currencySym:"£",
|
function round(n, dp) {
|
||||||
|
if (dp===undefined) dp=1;
|
||||||
|
var p = Math.min(dp,dp - Math.floor(Math.log(n)/Math.log(10)));
|
||||||
|
return n.toFixed(p);
|
||||||
|
}
|
||||||
|
exports = { name : "system", currencySym:"£",
|
||||||
translate : str=>str, // as-is
|
translate : str=>str, // as-is
|
||||||
date : (d,short) => short?("0"+d.getDate()).substr(-2)+"/"+("0"+(d.getMonth()+1)).substr(-2)+"/"+d.getFullYear():d.toString().substr(4,11), // Date to "Feb 28 2020" or "28/02/2020"(short)
|
date : (d,short) => short?("0"+d.getDate()).substr(-2)+"/"+("0"+(d.getMonth()+1)).substr(-2)+"/"+d.getFullYear():d.toString().substr(4,11), // Date to "Feb 28 2020" or "28/02/2020"(short)
|
||||||
time : (d,short) => { // Date to "4:15.28 pm" or "15:42"(short)
|
time : (d,short) => { // Date to "4:15.28 pm" or "15:42"(short)
|
||||||
|
var h = d.getHours(), m = d.getMinutes()
|
||||||
|
if ((require('Storage').readJSON('setting.json',1)||{})["12hour"])
|
||||||
|
h = (h%12==0) ? 12 : h%12; // 12 hour
|
||||||
if (short)
|
if (short)
|
||||||
return d.toString().substr(16,5);
|
return (" "+h).substr(-2)+":"+("0"+m).substr(-2);
|
||||||
else {
|
else {
|
||||||
var h = d.getHours(), m = d.getMinutes(), r = "am";
|
var r = "am";
|
||||||
if (h==0) { h=12; }
|
if (h==0) { h=12; }
|
||||||
else if (h>=12) {
|
else if (h>=12) {
|
||||||
if (h>12) h-=12;
|
if (h>12) h-=12;
|
||||||
|
|
@ -48,16 +56,30 @@ exports = { name : "en_GB", currencySym:"£",
|
||||||
return (" "+h).substr(-2)+":"+("0"+m).substr(-2)+"."+("0"+d.getSeconds()).substr(-2)+" "+r;
|
return (" "+h).substr(-2)+":"+("0"+m).substr(-2)+"."+("0"+d.getSeconds()).substr(-2)+" "+r;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
dow : (d,short) => short?d.toString().substr(0,3):"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(",")[d.getDay()], // Date to "Monday" or "Mon"(short)
|
dow : (d,short) => "Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(",")[d.getDay()].substr(0, short ? 3 : 10), // Date to "Monday" or "Mon"(short)
|
||||||
month : (d,short) => short?d.toString().substr(4,3):"January,February,March,April,May,June,July,August,September,October,November,December".split(",")[d.getMonth()], // Date to "February" or "Feb"(short)
|
month : (d,short) => "January,February,March,April,May,June,July,August,September,October,November,December".split(",")[d.getMonth()].substr(0, short ? 3 : 10), // Date to "February" or "Feb"(short)
|
||||||
number : n => n.toString(), // more fancy?
|
number: (n, dec) => {
|
||||||
currency : n => "£"+n.toFixed(2), // number to "£1.00"
|
if (dec == null) dec = 2;
|
||||||
distance : m => (m<1000)?Math.round(m)+"m":Math.round(m/160.934)/10+"mi", // meters to "123m" or "1.2mi" depending on size
|
var w = n.toFixed(dec),
|
||||||
speed : s => Math.round(s*0.621371)+"mph",// kph to "123mph"
|
k = w|0,
|
||||||
temp : t => Math.round(t)+"'C" // degrees C to degrees C
|
b = n < 0 ? 1 : 0,
|
||||||
meridian: d => (d.getHours() <= 12) ? "am":"pm",
|
u = Math.abs(w-k),
|
||||||
|
d = (''+u.toFixed(dec)).substr(2, dec),
|
||||||
|
s = ''+k,
|
||||||
|
i = s.length,
|
||||||
|
r = '';
|
||||||
|
while ((i-=3) > b)
|
||||||
|
r = ',' + s.substr(i, 3) + r;
|
||||||
|
return s.substr(0, i + 3) + r + (d ? '.' + d: '');
|
||||||
|
},
|
||||||
|
currency : n => {console.log("Warning: Currency information is deprecated");return "£"+n.toFixed(2)}, // number to "£1.00"
|
||||||
|
distance : (m,dp) => (m<1000)?round(m,dp)+"m":round(m/1000,dp)+"km", // meters to "123m" or "1.2km" depending on size
|
||||||
|
speed : (s,dp) => round(s/1.60934,dp)+"mph",// kph to "123mph"
|
||||||
|
temp : (t,dp) => round(t,dp)+"'C", // degrees C to degrees C
|
||||||
|
meridian: d => (d.getHours() <= 12) ? "am":"pm" // Date to am/pm
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
function codePageLookup(lang, codePage, ch) {
|
function codePageLookup(lang, codePage, ch) {
|
||||||
var chCode = ch.charCodeAt();
|
var chCode = ch.charCodeAt();
|
||||||
|
|
@ -207,9 +229,8 @@ exports = {
|
||||||
s = ''+k,
|
s = ''+k,
|
||||||
i = s.length,
|
i = s.length,
|
||||||
r = '';
|
r = '';
|
||||||
while ((i-=3) > b) {
|
while ((i-=3) > b)
|
||||||
r = '${locale.thousands_sep}' + s.substr(i, 3) + r;
|
r = '${locale.thousands_sep}' + s.substr(i, 3) + r;
|
||||||
}
|
|
||||||
return s.substr(0, i + 3) + r + (d ? '${locale.decimal_point}' + d: '');
|
return s.substr(0, i + 3) + r + (d ? '${locale.decimal_point}' + d: '');
|
||||||
},
|
},
|
||||||
currency: n => ${currency},
|
currency: n => ${currency},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue