feat: add String localization support

Signed-off-by: The one with the braid <the-one@with-the-braid.cf>
This commit is contained in:
The one with the braid 2023-08-27 18:58:07 +02:00
parent 78f88305ec
commit e345763813
10 changed files with 173 additions and 13 deletions

View file

@ -21,6 +21,32 @@ Some parts of the PkPass specification are either not yet implemented, or not pl
- `nfc`: Card payment information for Apple Pay. - Not planned, feel free to contribute.
- `webService`: Information used to update passes using the web service. - Planned, feel free to contribute.
## Localizations
This package aims to implement PkPass localizations as well as possible. Any localizable value
can be accessed using a `getLocalized...` method, e.g. `myPass.getLocalizedDescription()` taking a `Locale`
as argument. In case the requested locale is not available, the following fallbacks are used:
- `en` - English, any
- `zh` - Chinese, generic language group
- `hi` - Hindi
- `es` - Spanish
- `fr` - French
- *In case neither available, take just any language you can find. We are likely dealing with a local product then.*
The used fallback languages are the five mostly understood languages in the world, feel free to propose better or more
precise fallback mechanisms.
## Barcode encodings
The PkPass standard is quite vague about the Barcode String encoding used. Technically, all IANA character set names
are allowed. Since this might be some overhead to implement, the following encoders are supported by default:
- `Latin1Codec` (default according to PkPass spec) - `iso-8859-1`, also fallback onto `iso-8859` and `iso8859`
- `Utf8Codec` (most common one) - `utf-8`, also fallback onto `utf8`
The supported encoders can be extended by adding a `String` `Encoder` pair to `PassBarcode.supportedCodecs`.
## Dependencies and compatibility
Any package should keep its dependencies as minimal as possible. Sometimes, there are specifications making this