mirror of
https://gitlab.com/TheOneWithTheBraid/dart_pkpass.git
synced 2025-07-06 05:18:47 +00:00
feat: add String localization support
Signed-off-by: The one with the braid <the-one@with-the-braid.cf>
This commit is contained in:
parent
78f88305ec
commit
e345763813
10 changed files with 173 additions and 13 deletions
|
@ -1,3 +1,6 @@
|
|||
import 'package:intl/locale.dart';
|
||||
|
||||
import 'package:pkpass/pkpass.dart';
|
||||
import 'package:pkpass/src/models/barcode.dart';
|
||||
import 'package:pkpass/src/utils/mabe_decode.dart';
|
||||
import 'beacon.dart';
|
||||
|
@ -191,4 +194,22 @@ class PassMetadata {
|
|||
webServiceURL: json['webServiceURL'] as String?,
|
||||
),
|
||||
);
|
||||
|
||||
/// Localized version of [description] based on given [locale] and [pass].
|
||||
String getLocalizedDescription(PassFile pass, Locale? locale) {
|
||||
final localizations = pass.getLocalizations(locale);
|
||||
return localizations?[description] ?? description;
|
||||
}
|
||||
|
||||
/// Localized version of [organizationName] based on given [locale] and [pass].
|
||||
String getLocalizedOrganizationName(PassFile pass, Locale? locale) {
|
||||
final localizations = pass.getLocalizations(locale);
|
||||
return localizations?[organizationName] ?? organizationName;
|
||||
}
|
||||
|
||||
/// Localized version of [logoText] based on given [locale] and [pass].
|
||||
String? getLocalizedLogoText(PassFile pass, Locale? locale) {
|
||||
final localizations = pass.getLocalizations(locale);
|
||||
return localizations?[logoText] ?? logoText;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue