EZTIME_LANGUAGE

separated the languages in lang dir
added spanish
added documentation
pull/59/head
Rop 6 years ago
parent 319ce28242
commit dd96672481

@ -42,6 +42,8 @@ Overlooking the battlefield after implementing some part of this, it seemed like
**time-saving**: No more time spent on writing code to print date or time in some nicer way. Print things like "8:20 PM" or "Saturday the 23rd of August 2018" with ease. Prevent display-flicker with `minuteChanged()` and `secondChanged()` functions without storing any values to compare.
**multilingual**: Can display names of days and months in different languages. Easy to add your own language.
**small enough**: Works with all features and full debugging information on an old Arduino Uno with an Ethernet Shield, leaving 2/3 of RAM and even some of the flash for you to work with. Various `#define` options let you leave parts of the library out if you want to make it smaller: you can even leave out the networking altogether if you have a different time source.
**easy to use**: Don't believe it until you see it. Have a look at some of these examples to see how easy it is to use.
@ -605,6 +607,12 @@ These functions will take a numeric argument and convert it to the name of the d
 
### different languages
If you edit the ezTime.h file in the library directory and set the EZTIME_LANGUAGE define to NL or DE, you will get the names of the months and days in Dutch or German respectively. The functions that return these names are separated out in files in the `src/lang` directory, the files there will show you what languages are currently supported. If you add a file in this directory you will add a language, it is that easy. Please submit the files you make via a pull request so others can use ezTime in their own language too.
 
## Events
### events
@ -978,6 +986,7 @@ ezTime 0.7.2 runs fine (No networking on board, so tested with NoNetwork example
* [<em>militaryTZ</em>](#militarytz)
* [secondChanged and minuteChanged](#secondchanged-and-minutechanged)
* [names of days and months](#names-of-days-and-months)
* [different languages](#different-languages)
* [Events](#events)
* [events](#events-1)
* [setEvent](#setevent)

@ -149,108 +149,20 @@ namespace ezt {
infoln(debugLevelString(level));
}
////////////////////////
#ifdef EZTIME_LANG_DE
String monthStr(const uint8_t month) {
switch(month) {
case 1: return F("Januar");
case 2: return F("Februar");
case 3: return F("März");
case 4: return F("April");
case 5: return F("Mai");
case 6: return F("Juni");
case 7: return F("Juli");
case 8: return F("August");
case 9: return F("September");
case 10: return F("Oktober");
case 11: return F("November");
case 12: return F("Dezember");
}
return "";
}
String dayStr(const uint8_t day) {
switch(day) {
case 1: return F("Sonntag");
case 2: return F("Montag");
case 3: return F("Dienstag");
case 4: return F("Mittwoch");
case 5: return F("Donnerstag");
case 6: return F("Freitag");
case 7: return F("Samstag");
}
return "";
}
#elif EZTIME_LANG_NL
String monthStr(const uint8_t month) {
switch(month) {
case 1: return F("Januari");
case 2: return F("Februari");
case 3: return F("Maart");
case 4: return F("April");
case 5: return F("Mei");
case 6: return F("Juni");
case 7: return F("Juli");
case 8: return F("Augustus");
case 9: return F("September");
case 10: return F("October");
case 11: return F("November");
case 12: return F("December");
}
return "";
}
// The include below includes the dayStr, dayShortStr, monthStr and monthShortStr from the appropriate language file
// in the /src/lang subdirectory.
String dayStr(const uint8_t day) {
switch(day) {
case 1: return F("Zondag");
case 2: return F("Maandag");
case 3: return F("Dinsdag");
case 4: return F("Woensdag");
case 5: return F("Donderdag");
case 6: return F("Vrijdag");
case 7: return F("Zaterdag");
}
return "";
}
#else
String monthStr(const uint8_t month) {
switch(month) {
case 1: return F("January");
case 2: return F("February");
case 3: return F("March");
case 4: return F("April");
case 5: return F("May");
case 6: return F("June");
case 7: return F("July");
case 8: return F("August");
case 9: return F("September");
case 10: return F("October");
case 11: return F("November");
case 12: return F("December");
}
return "";
}
String dayStr(const uint8_t day) {
switch(day) {
case 1: return F("Sunday");
case 2: return F("Monday");
case 3: return F("Tuesday");
case 4: return F("Wednesday");
case 5: return F("Thursday");
case 6: return F("Friday");
case 7: return F("Saturday");
}
return "";
}
#ifdef EZTIME_LANGUAGE
#define XSTR(x) #x
#define STR(x) XSTR(x)
#include STR(lang/EZTIME_LANGUAGE)
#else
#include "lang/ezTime_EN"
#endif
// Original time lib compatibility
String dayShortStr(const uint8_t day) { return dayStr(day).substring(0,3); }
String monthShortStr(const uint8_t month) { return monthStr(month).substring(0,3); }
//
timeStatus_t timeStatus() { return _time_status; }
@ -1306,15 +1218,9 @@ String Timezone::dateTime(time_t t, const ezLocalOrUTC_t local_or_utc, const Str
case 'd': // Day of the month, 2 digits with leading zeros
out += ezt::zeropad(tm.Day, 2);
break;
#ifdef EZTIME_TWO_LETTER_DAY
case 'D': // A textual representation of a day, two letters
out += ezt::dayStr(tm.Wday).substring(0,2);
break;
#else
case 'D': // A textual representation of a day, three letters
out += ezt::dayStr(tm.Wday).substring(0,3);
break;
#endif
case 'D': // A textual representation of a day, usually two or three letters
out += ezt::dayShortStr(tm.Wday);
break;
case 'j': // Day of the month without leading zeros
out += String(tm.Day);
break;
@ -1351,8 +1257,8 @@ String Timezone::dateTime(time_t t, const ezLocalOrUTC_t local_or_utc, const Str
case 'm': // Numeric representation of a month, with leading zeros
out += ezt::zeropad(tm.Month, 2);
break;
case 'M': // A short textual representation of a month, three letters
out += ezt::monthStr(tm.Month).substring(0,3);
case 'M': // A short textual representation of a month, usually three letters
out += ezt::monthShortStr(tm.Month);
break;
case 'n': // Numeric representation of a month, without leading zeros
out += String(tm.Month);

@ -4,6 +4,8 @@
#ifdef __cplusplus
#define _EZTIME_H_
//Sets the language for the names of Months and Days. See the src/lang directory for supported languages
#define EZTIME_LANGUAGE EN
// Compiles in NTP updating, timezoned fetching and caching
#define EZTIME_NETWORK_ENABLE

@ -0,0 +1,34 @@
String monthStr(const uint8_t month) {
switch(month) {
case 1: return F("Januar");
case 2: return F("Februar");
case 3: return F("März");
case 4: return F("April");
case 5: return F("Mai");
case 6: return F("Juni");
case 7: return F("Juli");
case 8: return F("August");
case 9: return F("September");
case 10: return F("Oktober");
case 11: return F("November");
case 12: return F("Dezember");
}
return "";
}
String monthShortStr(const uint8_t month) { return monthStr(month).substring(0,3); }
String dayStr(const uint8_t day) {
switch(day) {
case 1: return F("Sonntag");
case 2: return F("Montag");
case 3: return F("Dienstag");
case 4: return F("Mittwoch");
case 5: return F("Donnerstag");
case 6: return F("Freitag");
case 7: return F("Samstag");
}
return "";
}
String dayShortStr(const uint8_t day) { return dayStr(day).substring(0,2); }

@ -0,0 +1,34 @@
String monthStr(const uint8_t month) {
switch(month) {
case 1: return F("January");
case 2: return F("February");
case 3: return F("March");
case 4: return F("April");
case 5: return F("May");
case 6: return F("June");
case 7: return F("July");
case 8: return F("August");
case 9: return F("September");
case 10: return F("October");
case 11: return F("November");
case 12: return F("December");
}
return "";
}
String monthShortStr(const uint8_t month) { return monthStr(month).substring(0,3); }
String dayStr(const uint8_t day) {
switch(day) {
case 1: return F("Sunday");
case 2: return F("Monday");
case 3: return F("Tuesday");
case 4: return F("Wednesday");
case 5: return F("Thursday");
case 6: return F("Friday");
case 7: return F("Saturday");
}
return "";
}
String dayShortStr(const uint8_t day) { return dayStr(day).substring(0,3); }

@ -0,0 +1,45 @@
String monthStr(const uint8_t month) {
switch(month) {
case 1: return F("enero");
case 2: return F("febrero");
case 3: return F("marzo");
case 4: return F("abril");
case 5: return F("mayo");
case 6: return F("junio");
case 7: return F("julio");
case 8: return F("agosto");
case 9: return F("septiembre");
case 10: return F("octubre");
case 11: return F("noviembre");
case 12: return F("diciembre");
}
return "";
}
String monthShortStr(const uint8_t month) { return monthStr(month).substring(0,3); }
String dayStr(const uint8_t day) {
switch(day) {
case 1: return F("domingo");
case 2: return F("lunes");
case 3: return F("martes");
case 4: return F("miercoles");
case 5: return F("jueves");
case 6: return F("viernes");
case 7: return F("sabado");
}
return "";
}
String dayShortStr(const uint8_t day) {
switch(day) {
case 1: return F("D");
case 2: return F("L");
case 3: return F("M");
case 4: return F("X");
case 5: return F("J");
case 6: return F("V");
case 7: return F("S");
}
return "";
}

@ -0,0 +1,34 @@
String monthStr(const uint8_t month) {
switch(month) {
case 1: return F("januari");
case 2: return F("februari");
case 3: return F("maart");
case 4: return F("april");
case 5: return F("mei");
case 6: return F("juni");
case 7: return F("juli");
case 8: return F("augustus");
case 9: return F("september");
case 10: return F("october");
case 11: return F("november");
case 12: return F("december");
}
return "";
}
String monthShortStr(const uint8_t month) { return monthStr(month).substring(0,3); }
String dayStr(const uint8_t day) {
switch(day) {
case 1: return F("zondag");
case 2: return F("maandag");
case 3: return F("dinsdag");
case 4: return F("woensdag");
case 5: return F("donderdag");
case 6: return F("vrijdag");
case 7: return F("zaterdag");
}
return "";
}
String dayShortStr(const uint8_t day) { return dayStr(day).substring(0,2); }
Loading…
Cancel
Save