1
1
#include < LittleFS.h>
2
2
#include < YAMLDuino.h>
3
3
4
-
5
4
#include < vector>
6
5
static std::vector<String> i18nFiles;
6
+
7
7
const char * extension = " yml" ;
8
8
const char * path = " /lang" ;
9
9
@@ -14,14 +14,14 @@ void setup()
14
14
Serial.begin (115200 );
15
15
LittleFS.begin ();
16
16
17
- Serial.printf ( " [%d] %s \n " , ESP. getFreeHeap (), " Hello i18n test" );
17
+ Serial.println ( " Hello i18n test" );
18
18
19
19
// scan the lang folder and store filenames in an array
20
20
21
21
File dir = LittleFS.open ( path );
22
22
23
23
if ( !dir ) {
24
- Serial.printf (" Error, can't access filesystem, halting" );
24
+ Serial.println (" Error, can't access filesystem, halting" );
25
25
while (1 ) vTaskDelay (1 );
26
26
}
27
27
@@ -47,21 +47,21 @@ void loop()
47
47
{
48
48
int randLang = rand ()%(i18nFiles.size ());
49
49
50
- int free_heap_before_load = ESP. getFreeHeap ();
50
+ int free_heap_before_load = HEAP_AVAILABLE ();
51
51
52
52
if (! i18n.setLocale (i18nFiles[randLang].c_str ()) ) {
53
53
54
- Serial. printf ( " [%d] Error loading locale %s, halting\n " , ESP. getFreeHeap () , i18nFiles[randLang].c_str ());
54
+ YAML_LOG_n ( " Error loading locale %s, halting\n " , i18nFiles[randLang].c_str ());
55
55
56
56
while (1 ) vTaskDelay (1 );
57
57
}
58
58
59
- int free_heap_after_load = ESP. getFreeHeap ();
59
+ int free_heap_after_load = HEAP_AVAILABLE ();
60
60
61
- Serial. printf ( " [%d-%d] Locale file %s loaded\n " , free_heap_before_load, free_heap_after_load, i18nFiles[randLang].c_str ());
61
+ YAML_LOG_n ( " [%d-%d] Locale file %s loaded\n " , free_heap_before_load, free_heap_after_load, i18nFiles[randLang].c_str ());
62
62
63
- Serial.printf ( " [%d] %s \n " , ESP. getFreeHeap (), i18n.gettext (" activerecord:errors:messages:record_invalid" ) ); // "La validation a échoué : %{errors}"
64
- Serial.printf ( " [%d] %s \n " , ESP. getFreeHeap (), i18n.gettext (" date:abbr_day_names:2" ) ); // "mar"
65
- Serial.printf ( " [%d] %s \n " , ESP. getFreeHeap (), i18n.gettext (" time:pm" ) ); // "pm", last element
63
+ Serial.println ( i18n.gettext (" activerecord:errors:messages:record_invalid" ) ); // "La validation a échoué : %{errors}"
64
+ Serial.println ( i18n.gettext (" date:abbr_day_names:2" ) ); // "mar"
65
+ Serial.println ( i18n.gettext (" time:pm" ) ); // "pm", last element
66
66
delay ( 1000 );
67
67
}
0 commit comments