localized weekdays
parent
467173ad9e
commit
a572e02813
|
@ -38,7 +38,7 @@
|
||||||
"chalk"
|
"chalk"
|
||||||
],
|
],
|
||||||
"uuid": "793bab03-9464-48a2-b63f-3f779c473db8",
|
"uuid": "793bab03-9464-48a2-b63f-3f779c473db8",
|
||||||
"versionLabel": "4.9",
|
"versionLabel": "4.10",
|
||||||
"watchapp": {
|
"watchapp": {
|
||||||
"watchface": true
|
"watchface": true
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,12 @@ String.prototype.hashCode = function(){
|
||||||
return hash;
|
return hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
var debugwatches = Array(/*1568511776, */1135189913, -826258655);
|
var debugwatches = Array(1568511776, 1135189913, -826258655);
|
||||||
|
var tokenhash;
|
||||||
|
|
||||||
Pebble.addEventListener('ready', function() {
|
Pebble.addEventListener('ready', function() {
|
||||||
console.log('PebbleKit JS ready!');
|
console.log('PebbleKit JS ready!');
|
||||||
var tokenhash = Pebble.getWatchToken().hashCode();
|
tokenhash = Pebble.getWatchToken().hashCode();
|
||||||
console.log('Watch identifier '+tokenhash);
|
console.log('Watch identifier '+tokenhash);
|
||||||
if (debugwatches.indexOf(tokenhash) > -1) {
|
if (debugwatches.indexOf(tokenhash) > -1) {
|
||||||
var dict = {"debugwatch": 1};
|
var dict = {"debugwatch": 1};
|
||||||
|
@ -37,6 +38,10 @@ Pebble.addEventListener('showConfiguration', function() {
|
||||||
} else if (watch.platform == "aplite") {
|
} else if (watch.platform == "aplite") {
|
||||||
url += "&rect=true&bw=true";
|
url += "&rect=true&bw=true";
|
||||||
}
|
}
|
||||||
|
tokenhash = Pebble.getWatchToken().hashCode();
|
||||||
|
if (debugwatches.indexOf(tokenhash) > -1) {
|
||||||
|
url += "&debug=true";
|
||||||
|
}
|
||||||
console.log('Showing configuration page: '+url);
|
console.log('Showing configuration page: '+url);
|
||||||
Pebble.openURL(url);
|
Pebble.openURL(url);
|
||||||
});
|
});
|
||||||
|
|
|
@ -203,6 +203,36 @@ unsigned char blocks[][5][5] = {{
|
||||||
{1,1,1,1,1}
|
{1,1,1,1,1}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
LANG_EN,
|
||||||
|
LANG_DE,
|
||||||
|
LANG_ES,
|
||||||
|
LANG_FR,
|
||||||
|
LANG_IT,
|
||||||
|
LANG_PT
|
||||||
|
};
|
||||||
|
|
||||||
|
const char* weekdays[][7] = {
|
||||||
|
[LANG_EN]={
|
||||||
|
"SU","MO","TU","WE","TH","FR","SA"
|
||||||
|
},
|
||||||
|
[LANG_DE]={
|
||||||
|
"SO","MO","DI","MI","DO","FR","SA"
|
||||||
|
},
|
||||||
|
[LANG_ES]={ // from https://forums.getpebble.com/discussion/comment/166975/#Comment_166975
|
||||||
|
"DO","LU","MA","MI","JU","VI","SA"
|
||||||
|
},
|
||||||
|
[LANG_FR]={ // from https://www.quora.com/How-are-days-of-the-week-abbreviated-in-various-languages
|
||||||
|
"DI","LU","MA","ME","JE","VE","SA"
|
||||||
|
},
|
||||||
|
[LANG_IT]={ // from https://www.quora.com/How-are-days-of-the-week-abbreviated-in-various-languages
|
||||||
|
"DO","LU","MA","ME","GI","VE","SA"
|
||||||
|
},
|
||||||
|
[LANG_PT]={ // from http://www.brazil-help.com/week.htm
|
||||||
|
"DO","SG","TE","QA","QI","SX","SA"
|
||||||
|
}
|
||||||
|
}; // required Letters: ADEFGHIJLMOQRSTUVWX
|
||||||
|
|
||||||
unsigned char alphablocks[][5][5] = {
|
unsigned char alphablocks[][5][5] = {
|
||||||
[65] = { // A
|
[65] = { // A
|
||||||
{1,1,1,1,1},
|
{1,1,1,1,1},
|
||||||
|
@ -232,6 +262,13 @@ unsigned char alphablocks[][5][5] = {
|
||||||
{1,0,0,0,0},
|
{1,0,0,0,0},
|
||||||
{1,0,2,2,2}
|
{1,0,2,2,2}
|
||||||
},
|
},
|
||||||
|
[71] = { // G
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{1,0,0,0,0},
|
||||||
|
{1,0,1,1,1},
|
||||||
|
{1,0,0,0,1},
|
||||||
|
{1,1,1,1,1}
|
||||||
|
},
|
||||||
[72] = { // H
|
[72] = { // H
|
||||||
{1,0,2,0,1},
|
{1,0,2,0,1},
|
||||||
{1,0,0,0,1},
|
{1,0,0,0,1},
|
||||||
|
@ -274,6 +311,13 @@ unsigned char alphablocks[][5][5] = {
|
||||||
{1,0,0,0,1},
|
{1,0,0,0,1},
|
||||||
{1,1,1,1,1}
|
{1,1,1,1,1}
|
||||||
},
|
},
|
||||||
|
[81] = { // Q
|
||||||
|
{1,1,1,1,1},
|
||||||
|
{1,0,0,0,1},
|
||||||
|
{1,0,0,0,1},
|
||||||
|
{1,0,1,0,1},
|
||||||
|
{1,1,1,1,1}
|
||||||
|
},
|
||||||
[82] = { // R
|
[82] = { // R
|
||||||
{1,1,1,1,1},
|
{1,1,1,1,1},
|
||||||
{0,0,0,0,1},
|
{0,0,0,0,1},
|
||||||
|
@ -316,6 +360,13 @@ unsigned char alphablocks[][5][5] = {
|
||||||
{1,0,1,0,1},
|
{1,0,1,0,1},
|
||||||
{1,1,1,1,1}
|
{1,1,1,1,1}
|
||||||
},
|
},
|
||||||
|
[88] = { // X
|
||||||
|
{1,0,2,0,1},
|
||||||
|
{0,1,0,1,0},
|
||||||
|
{2,0,1,0,2},
|
||||||
|
{0,1,0,1,0},
|
||||||
|
{1,0,2,0,1}
|
||||||
|
},
|
||||||
[10] = {
|
[10] = {
|
||||||
{2,2,2,2,2},
|
{2,2,2,2,2},
|
||||||
{0,0,0,0,0},
|
{0,0,0,0,0},
|
||||||
|
@ -638,23 +689,34 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
//ho = 9;
|
//ho = 9;
|
||||||
}
|
}
|
||||||
|
const char* locale;
|
||||||
if (WEEKDAY) {
|
uint8_t localeid;
|
||||||
strftime(weekday_buffer, sizeof(weekday_buffer), "%a", t);
|
char weekdayname[5];
|
||||||
for (int i=0; i<2; i++) {
|
locale = i18n_get_system_locale();
|
||||||
if ((int) weekday_buffer[i] == 225) { // á
|
if (WEEKDAY) {
|
||||||
weekday_buffer[i] = 65; // A
|
strftime(weekday_buffer, sizeof(weekday_buffer), "%w", t);
|
||||||
}
|
if (strncmp("de", locale, 2) == 0) {
|
||||||
if ((int) weekday_buffer[i] > 90) { // lower case
|
localeid = 1;
|
||||||
weekday_buffer[i] =weekday_buffer[i]-0x20; // make upper case
|
} else if (strncmp("es", locale, 2) == 0) {
|
||||||
}
|
localeid = 2;
|
||||||
|
} else if (strncmp("fr", locale, 2) == 0) {
|
||||||
|
localeid = 3;
|
||||||
|
} else if (strncmp("it", locale, 2) == 0) {
|
||||||
|
localeid = 4;
|
||||||
|
} else if (strncmp("pt", locale, 2) == 0) {
|
||||||
|
localeid = 5;
|
||||||
|
} else {
|
||||||
|
localeid = 0;
|
||||||
}
|
}
|
||||||
|
uint8_t weekdaynum = ((int)weekday_buffer[0])-0x30;
|
||||||
|
strcpy(weekdayname, weekdays[localeid][weekdaynum]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) {
|
if (debug) {
|
||||||
APP_LOG(APP_LOG_LEVEL_INFO, "It is now %d:%d %d.%d.", (int)ho, (int)mi, (int)da, (int)mo);
|
APP_LOG(APP_LOG_LEVEL_INFO, "It is now %d:%d %d.%d.", (int)ho, (int)mi, (int)da, (int)mo);
|
||||||
if (WEEKDAY) {
|
if (WEEKDAY) {
|
||||||
APP_LOG(APP_LOG_LEVEL_INFO, "The Weekday is %c%c", weekday_buffer[0], weekday_buffer[1]);
|
APP_LOG(APP_LOG_LEVEL_INFO, "Locale is %s", locale);
|
||||||
|
APP_LOG(APP_LOG_LEVEL_INFO, "The Weekday is %c%c", weekdayname[0], weekdayname[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,8 +764,8 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
||||||
if (WEEKDAY) {
|
if (WEEKDAY) {
|
||||||
slot[4].isalpha = true;
|
slot[4].isalpha = true;
|
||||||
slot[5].isalpha = true;
|
slot[5].isalpha = true;
|
||||||
slot[4].curDigit = (int) weekday_buffer[0];
|
slot[4].curDigit = (int) weekdayname[0];
|
||||||
slot[5].curDigit = (int) weekday_buffer[1];
|
slot[5].curDigit = (int) weekdayname[1];
|
||||||
} else {
|
} else {
|
||||||
slot[4].curDigit = mo/10;
|
slot[4].curDigit = mo/10;
|
||||||
slot[5].curDigit = mo%10;
|
slot[5].curDigit = mo%10;
|
||||||
|
@ -725,8 +787,8 @@ void handle_tick(struct tm *t, TimeUnits units_changed) {
|
||||||
if (WEEKDAY) {
|
if (WEEKDAY) {
|
||||||
slot[6].isalpha = true;
|
slot[6].isalpha = true;
|
||||||
slot[7].isalpha = true;
|
slot[7].isalpha = true;
|
||||||
slot[6].curDigit = (int) weekday_buffer[0];
|
slot[6].curDigit = (int) weekdayname[0];
|
||||||
slot[7].curDigit = (int) weekday_buffer[1];
|
slot[7].curDigit = (int) weekdayname[1];
|
||||||
} else {
|
} else {
|
||||||
if (CENTER_DATE && mo < 10) {
|
if (CENTER_DATE && mo < 10) {
|
||||||
slot[6].curDigit = mo%10;
|
slot[6].curDigit = mo%10;
|
||||||
|
|
Loading…
Reference in New Issue