1 /* 2 * Copyright 2019, Andrew Lindesay <apl@lindesay.co.nz>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef LOCALE_UTILS_H 6 #define LOCALE_UTILS_H 7 8 9 #include <String.h> 10 11 12 #include "Language.h" 13 #include "LanguageRepository.h" 14 15 16 class BCollator; 17 18 19 class LocaleUtils { 20 21 public: 22 static BCollator* GetSharedCollator(); 23 24 static BString TimestampToDateTimeString(uint64 millis); 25 static BString TimestampToDateString(uint64 millis); 26 27 static BString CreateTranslatedIAmMinimumAgeSlug(int minimumAge); 28 29 static LanguageRef DeriveDefaultLanguage(LanguageRepository* repository); 30 31 static void SetForcedSystemDefaultLanguageID(const BString& id); 32 // exposed for testing 33 34 private: 35 36 static LanguageRef _FindBestMatchingLanguage(LanguageRepository* repository, 37 const char* code, const char* countryCode, 38 const char* scriptCode); 39 40 static LanguageRef _DeriveSystemDefaultLanguage(); 41 42 static int32 _IndexOfBestMatchingLanguage(LanguageRepository* repository, 43 const char* code, const char* countryCode, 44 const char* scriptCode); 45 46 static void _GetCollator(BCollator* collator); 47 48 private: 49 static BCollator* sSharedCollator; 50 51 static BString sForcedSystemDefaultLanguageID; 52 }; 53 54 55 #endif // LOCALE_UTILS_H 56