summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-12-03 22:42:04 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-12-03 22:42:04 +0000
commit3aeb1a8758a3a59066ddf9246e5803dfe7eda0bf (patch)
treecbfea67b8aa2789fd7b5becc4302a97afa49832b
parent86cbe7adb4be2b2e992f51fbbb2fccb6d7ab9ad4 (diff)
parentb3bee1d7f9fefa4ca0946bb163b33ee9069b52bd (diff)
downloadminikin-3aeb1a8758a3a59066ddf9246e5803dfe7eda0bf.tar.gz
Merge "Add method that convert locale list ID to string"
-rw-r--r--include/minikin/LocaleList.h2
-rw-r--r--libs/minikin/Locale.cpp12
2 files changed, 14 insertions, 0 deletions
diff --git a/include/minikin/LocaleList.h b/include/minikin/LocaleList.h
index bfc26c7..9c14b63 100644
--- a/include/minikin/LocaleList.h
+++ b/include/minikin/LocaleList.h
@@ -26,6 +26,8 @@ namespace minikin {
// TODO: Introduce LocaleId type.
uint32_t registerLocaleList(const std::string& locales);
+std::string getLocaleString(uint32_t id);
+
} // namespace minikin
#endif // MINIKIN_LOCALE_H
diff --git a/libs/minikin/Locale.cpp b/libs/minikin/Locale.cpp
index c1ec389..553f61a 100644
--- a/libs/minikin/Locale.cpp
+++ b/libs/minikin/Locale.cpp
@@ -34,6 +34,18 @@ uint32_t registerLocaleList(const std::string& locales) {
return LocaleListCache::getId(locales);
}
+std::string getLocaleString(uint32_t localeId) {
+ const LocaleList& localeList = LocaleListCache::getById(localeId);
+ std::string out;
+ for (size_t i = 0; i < localeList.size(); ++i) {
+ if (i != 0) {
+ out += ",";
+ }
+ out += localeList[i].getString();
+ }
+ return out;
+}
+
// Check if a language code supports extension such as emoji and line break etc. according to its
// subtag
static bool isSubtag(const char* buf, size_t bufLen, const char* subtag, size_t subtagLen) {