Skip to content

Commit ce32b4e

Browse files
committed
disabling wio terminal (basic core too crappy)
1 parent 7254f03 commit ce32b4e

File tree

3 files changed

+63
-5
lines changed

3 files changed

+63
-5
lines changed

ReadMe.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,60 @@ YAML::setYAMLIndent( 3 );
252252
----------------------------
253253
254254
255+
## I18N and L10N
256+
257+
258+
Sample example `/lang/en-GB.yml` stored in LittleFS:
259+
260+
```yml
261+
en-GB:
262+
hello: world
263+
blah:
264+
my_array:
265+
- first
266+
- second
267+
- third
268+
269+
```
270+
271+
Load the module with `#include <i18n/i18n.hpp>`, assign a filesystem with `i18n.setFS()`
272+
and a locale with `i18n.setLocale()`, then use `i18n.gettext()` to access localized strings.
273+
274+
275+
```cpp
276+
277+
#include <LittleFS.h>
278+
#include <ArduinoJson.h>
279+
#define YAML_DISABLE_CJSON // not needed here
280+
#include <YAMLDuino.h>
281+
#include <i18n/i18n.hpp>
282+
283+
284+
void setup()
285+
{
286+
Serial.begin(115200);
287+
LittleFS.begin();
288+
289+
i18n.setFS( &LittleFS );
290+
i18n.setLocale("en-GB"); // loads "/lang/en-GB.yml" file from LittleFS
291+
292+
Serial.println( i18n.gettext("hello" ) ); // prints "world"
293+
Serial.println( i18n.gettext("blah:my_array:2" ) ); // prints "third"
294+
}
295+
296+
297+
void loop()
298+
{
299+
300+
delay(1000);
301+
}
302+
```
303+
304+
305+
----------------------------
306+
307+
308+
255309
## Debug
256310

257311

src/i18n/i18n.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
*
2929
\*/
3030

31+
#if !defined WIO_TERMINAL
32+
3133
#include "./i18n.hpp"
3234

3335
#include <vector>
@@ -249,3 +251,5 @@ bool i18n_t::loadLocale()
249251

250252
return true;
251253
}
254+
255+
#endif // defined WIO_TERMINAL

src/i18n/i18n.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@
3131
#pragma once
3232

3333

34-
#if defined WIO_TERMINAL
35-
#include <Seeed_FS.h>
36-
#else
37-
#include <FS.h>
38-
#endif
34+
#if !defined WIO_TERMINAL
35+
3936

37+
#include <FS.h>
4038

4139

4240
#include <ArduinoJson.h>
@@ -93,3 +91,5 @@ struct i18n_t
9391

9492

9593
static i18n_t i18n;
94+
95+
#endif // defined WIO_TERMINAL

0 commit comments

Comments
 (0)