<commit_before># locale_framework

Minimal framework to support locale features in Pebble apps, using 
[`i18n_get_system_locale()`](http://developer.getpebble.com/docs/c/group___internationalization.html) 
in Pebble Firmware 2.8+ to discover the system locale and select the correct
text to display.

## To Use

### Setting Up Your Project

* Add `localize.h`, `localize.c` and `hash.h` to your project's `src` directory.  

* Add `locale_english.bin`, `locale_french.bin`, `locale_spanish.bin` and
  `locale_german.bin` to your app resources.

> Note: Empty files (size 0) are used as placeholders so code can compile, and
> will fall back to English.

* Add `#include <localize.h>` to any code files that require translation.

* Modify your main function to use `init_locale()`:

```c
int main(void) {
  // Init locale framework
  locale_init();

  /* Other app setup code */

}
```

* For all strings that you wish to localize, add `_()` around them.

```c
_("Breakfast Time");
```

### Generating Translation Resources

* Run `python gen_dict.py src/ locale_english.json`. This will generate
  `locale_english.json` and `locale_english.bin`.<commit_msg>Fixed function name in README.md<commit_after># locale_framework

Minimal framework to support locale features in Pebble apps, using 
[`i18n_get_system_locale()`](http://developer.getpebble.com/docs/c/group___internationalization.html) 
in Pebble Firmware 2.8+ to discover the system locale and select the correct
text to display.

## To Use

### Setting Up Your Project

* Add `localize.h`, `localize.c` and `hash.h` to your project's `src` directory.  

* Add `locale_english.bin`, `locale_french.bin`, `locale_spanish.bin` and
  `locale_german.bin` to your app resources.

> Note: Empty files (size 0) are used as placeholders so code can compile, and
> will fall back to English.

* Add `#include <localize.h>` to any code files that require translation.

* Modify your main function to use `locale_init()`:

```c
int main(void) {
  // Init locale framework
  locale_init();

  /* Other app setup code */

}
```

* For all strings that you wish to localize, add `_()` around them.

```c
_("Breakfast Time");
```

### Generating Translation Resources

* Run `python gen_dict.py src/ locale_english.json`. This will generate
  `locale_english.json` and `locale_english.bin`.
{'fraction_non_alphanumeric': 0.11701671667381054, 'fraction_numerical': 0.0042863266180882984, 'mean_word_length': 4.453271028037383, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2154697', 'n_tokens_mistral': 772, 'n_tokens_neox': 735, 'n_words': 263}