Skip to content

Commit

Permalink
disabling wio terminal (basic core too crappy)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobozo committed Dec 14, 2022
1 parent 7254f03 commit ce32b4e
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
54 changes: 54 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,60 @@ YAML::setYAMLIndent( 3 );
----------------------------
## I18N and L10N
Sample example `/lang/en-GB.yml` stored in LittleFS:
```yml
en-GB:
hello: world
blah:
my_array:
- first
- second
- third
```

Load the module with `#include <i18n/i18n.hpp>`, assign a filesystem with `i18n.setFS()`
and a locale with `i18n.setLocale()`, then use `i18n.gettext()` to access localized strings.


```cpp

#include <LittleFS.h>
#include <ArduinoJson.h>
#define YAML_DISABLE_CJSON // not needed here
#include <YAMLDuino.h>
#include <i18n/i18n.hpp>


void setup()
{
Serial.begin(115200);
LittleFS.begin();

i18n.setFS( &LittleFS );
i18n.setLocale("en-GB"); // loads "/lang/en-GB.yml" file from LittleFS

Serial.println( i18n.gettext("hello" ) ); // prints "world"
Serial.println( i18n.gettext("blah:my_array:2" ) ); // prints "third"
}


void loop()
{

delay(1000);
}
```


----------------------------



## Debug


Expand Down
4 changes: 4 additions & 0 deletions src/i18n/i18n.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*
\*/

#if !defined WIO_TERMINAL

#include "./i18n.hpp"

#include <vector>
Expand Down Expand Up @@ -249,3 +251,5 @@ bool i18n_t::loadLocale()

return true;
}

#endif // defined WIO_TERMINAL
10 changes: 5 additions & 5 deletions src/i18n/i18n.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@
#pragma once


#if defined WIO_TERMINAL
#include <Seeed_FS.h>
#else
#include <FS.h>
#endif
#if !defined WIO_TERMINAL


#include <FS.h>


#include <ArduinoJson.h>
Expand Down Expand Up @@ -93,3 +91,5 @@ struct i18n_t


static i18n_t i18n;

#endif // defined WIO_TERMINAL

0 comments on commit ce32b4e

Please sign in to comment.