pebble
  • Tutorials
  • Get the SDK
  • Guides
  • Documentation
  • PebbleOS
  • Mobile App
  • Examples
  • Index 01
  • Community
  • Blog
  • More
Privacy
Cookies
Publish

PebbleOS

  • Overview
  • Start here
    • Getting started guide
    • Playground
  • Development
    • The pbl CLI
    • Build system
    • Emulator and simulator
    • Testing
    • Debugging
    • Conventions
  • System
    • Architecture overview
    • Kernel
    • Subsystems
      • Analytics
      • Bluetooth
      • Core dumps
      • CRC
      • File system
      • Internationalization
      • Input
      • Logging
      • Pebble protocol
      • Profiler
      • Shell
      • Console
      • Task watchdog
    • Drivers
    • Services
    • Libraries
    • Third-party
    • Application SDK
  • Hardware
    • Boards
    • Programmers
  • Community
    • Contribution Guidelines
  • Reference
    • Reference
    • Kconfig options

Internationalization

subsys/i18n/ translates strings with a gettext message catalog (an MO file). Its public API is include/pbl/i18n/i18n.h, enabled with CONFIG_I18N.

Translating

Strings are looked up by their English original. Without a catalog, or without a translation, the original is returned, so code is written in English and works the same before any language is installed:

text_layer_set_text(&data->title, pbl_i18n_get("Settings", data));
...
pbl_i18n_free_all(data);

pbl_i18n_get() caches the translation for an owner until it is freed; pbl_i18n_get_with_buffer() translates into a caller buffer and caches nothing. The i18n_ctx_* variants attach a context to tell identical originals apart. Strings that cannot be translated in place, such as constant initializers, are marked with pbl_i18n_noop() or pbl_i18n_ctx_noop() so they are still extracted. The build extracts every marked string into pebbleos.pot.

Catalogs

The subsystem does not know where catalogs are stored. Its user sets one with pbl_i18n_set_catalog(), providing a reader, its data and the catalog size; setting another catalog, or none, frees every cached translation. pbl_i18n_catalog_get_info() reads a catalog’s locale, language name and version from its header without setting it.

In the firmware, the language pack service (fw/services/language_pack/) sets the catalog of the selected language pack, read from system resources, and sets it again when the pack file changes. See Language pack management for how packs are installed and selected.

Generated from PebbleOS f3212a729. This page is maintained in the pebbleos repository: docs/subsystems/i18n.md.

Overview

  • Translating
  • Catalogs