AbstractOperations.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2021, Tim Flynn <trflynn89@pm.me>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/String.h>
  8. #include <AK/Variant.h>
  9. #include <AK/Vector.h>
  10. #include <LibJS/Forward.h>
  11. #include <LibJS/Runtime/Intl/DisplayNames.h>
  12. #include <LibJS/Runtime/Value.h>
  13. #include <LibUnicode/Forward.h>
  14. namespace JS::Intl {
  15. using Fallback = Variant<Empty, bool, StringView>;
  16. struct LocaleOptions {
  17. Value locale_matcher;
  18. };
  19. struct LocaleResult {
  20. String locale;
  21. };
  22. struct PatternPartition {
  23. StringView type;
  24. StringView value;
  25. };
  26. Optional<Unicode::LocaleID> is_structurally_valid_language_tag(StringView locale);
  27. String canonicalize_unicode_locale_id(Unicode::LocaleID& locale);
  28. Vector<String> canonicalize_locale_list(GlobalObject&, Value locales);
  29. Optional<String> best_available_locale(StringView const& locale);
  30. Vector<String> best_fit_supported_locales(Vector<String> const& requested_locales);
  31. Vector<String> lookup_supported_locales(Vector<String> const& requested_locales);
  32. Array* supported_locales(GlobalObject&, Vector<String> const& requested_locales, Value options);
  33. Object* coerce_options_to_object(GlobalObject& global_object, Value options);
  34. Value get_option(GlobalObject& global_object, Value options, PropertyName const& property, Value::Type type, Vector<StringView> const& values, Fallback fallback);
  35. Vector<PatternPartition> partition_pattern(StringView pattern);
  36. String insert_unicode_extension_and_canonicalize(Unicode::LocaleID locale_id, Unicode::LocaleExtension extension);
  37. LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptions const& options, Vector<StringView> relevant_extension_keys);
  38. Value canonical_code_for_display_names(GlobalObject&, DisplayNames::Type type, StringView code);
  39. }