11#include "rapidjson/document.h"
12#include "rapidjson/stringbuffer.h"
13#include "rapidjson/writer.h"
16#include "third_party/icu/source/common/unicode/bytestream.h"
17#include "third_party/icu/source/common/unicode/errorcode.h"
18#include "third_party/icu/source/common/unicode/locid.h"
19#include "third_party/icu/source/common/unicode/strenum.h"
20#include "third_party/icu/source/common/unicode/stringpiece.h"
21#include "third_party/icu/source/common/unicode/uloc.h"
27using fuchsia::intl::Profile;
30 const Profile& intl_profile) {
31 rapidjson::Document document;
32 auto& allocator = document.GetAllocator();
34 document.AddMember(
"method",
"setLocale", allocator);
35 rapidjson::Value
args(rapidjson::kArrayType);
37 for (
const auto& locale_id : intl_profile.locales()) {
38 UErrorCode error_code = U_ZERO_ERROR;
39 icu::Locale locale = icu::Locale::forLanguageTag(locale_id.id, error_code);
40 if (U_FAILURE(error_code)) {
41 FML_LOG(
ERROR) <<
"Error parsing locale ID \"" << locale_id.id <<
"\"";
44 args.PushBack(rapidjson::Value().SetString(locale.getLanguage(), allocator),
47 auto country = locale.getCountry() !=
nullptr ? locale.getCountry() :
"";
48 args.PushBack(rapidjson::Value().SetString(country, allocator), allocator);
50 auto script = locale.getScript() !=
nullptr ? locale.getScript() :
"";
51 args.PushBack(rapidjson::Value().SetString(
script, allocator), allocator);
54 locale.getVariant() !=
nullptr ? locale.getVariant() :
"";
58 [](
unsigned char c) {
return std::tolower(c); });
59 args.PushBack(rapidjson::Value().SetString(variant, allocator), allocator);
62 document.AddMember(
"args",
args, allocator);
64 rapidjson::StringBuffer
buffer;
65 rapidjson::Writer<rapidjson::StringBuffer> writer(
buffer);
66 document.Accept(writer);
67 auto data =
reinterpret_cast<const uint8_t*
>(
buffer.GetString());
A Mapping like NonOwnedMapping, but uses Free as its release proc.
static MallocMapping Copy(const T *begin, const T *end)
static const char * begin(const StringSlice &s)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
#define FML_LOG(severity)
fml::MallocMapping MakeLocalizationPlatformMessageData(const Profile &intl_profile)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
std::shared_ptr< const fml::Mapping > data