Skip to content

Commit

Permalink
doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
tobozo committed Dec 14, 2022
1 parent ce32b4e commit a9b0698
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,22 +254,12 @@ YAML::setYAMLIndent( 3 );
## I18N and L10N
Note: Support is disabled with WIO Terminal (needs a proper fs::FS implementation).
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.
* Load the module with `#include <i18n/i18n.hpp>`.
* Assign a filesystem with `i18n.setFS()`.
* Load a locale with `i18n.setLocale()`.
* Use `i18n.gettext()` to access localized strings.
```cpp
Expand All @@ -280,14 +270,24 @@ and a locale with `i18n.setLocale()`, then use `i18n.gettext()` to access locali
#include <YAMLDuino.h>
#include <i18n/i18n.hpp>
// Sample example `/lang/en-GB.yml` stored in LittleFS:
//
// en-GB:
// hello: world
// blah:
// my_array:
// - first
// - second
// - third
void setup()
{
Serial.begin(115200);
LittleFS.begin();
i18n.setFS( &LittleFS );
i18n.setLocale("en-GB"); // loads "/lang/en-GB.yml" file from LittleFS
i18n.setFS( &LittleFS ); // assign LittleFS
i18n.setLocale("en-GB"); // will load "/lang/en-GB.yml" language file
Serial.println( i18n.gettext("hello" ) ); // prints "world"
Serial.println( i18n.gettext("blah:my_array:2" ) ); // prints "third"
Expand Down

0 comments on commit a9b0698

Please sign in to comment.