| 
									
										
										
										
											2021-08-24 22:58:45 -04:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Copyright (c) 2021, Tim Flynn <trflynn89@pm.me> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <AK/String.h>
 | 
					
						
							|  |  |  | #include <AK/Variant.h>
 | 
					
						
							|  |  |  | #include <AK/Vector.h>
 | 
					
						
							|  |  |  | #include <LibJS/Forward.h>
 | 
					
						
							|  |  |  | #include <LibJS/Runtime/Intl/DisplayNames.h>
 | 
					
						
							|  |  |  | #include <LibJS/Runtime/Value.h>
 | 
					
						
							| 
									
										
										
										
											2021-09-01 22:08:15 -04:00
										 |  |  | #include <LibUnicode/Forward.h>
 | 
					
						
							| 
									
										
										
										
											2021-08-24 22:58:45 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace JS::Intl { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | using Fallback = Variant<Empty, bool, StringView>; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct LocaleOptions { | 
					
						
							|  |  |  |     Value locale_matcher; | 
					
						
							| 
									
										
										
										
											2021-09-10 11:04:54 -04:00
										 |  |  |     Optional<String> nu; | 
					
						
							| 
									
										
										
										
											2021-08-24 22:58:45 -04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct LocaleResult { | 
					
						
							|  |  |  |     String locale; | 
					
						
							| 
									
										
										
										
											2021-09-10 10:01:41 -04:00
										 |  |  |     String data_locale; | 
					
						
							| 
									
										
										
										
											2021-09-10 11:04:54 -04:00
										 |  |  |     Optional<String> nu; | 
					
						
							| 
									
										
										
										
											2021-08-24 22:58:45 -04:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-06 14:37:23 -04:00
										 |  |  | struct PatternPartition { | 
					
						
							|  |  |  |     StringView type; | 
					
						
							|  |  |  |     StringView value; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-01 22:08:15 -04:00
										 |  |  | Optional<Unicode::LocaleID> is_structurally_valid_language_tag(StringView locale); | 
					
						
							| 
									
										
										
										
											2021-09-11 07:58:33 -04:00
										 |  |  | String canonicalize_unicode_locale_id(Unicode::LocaleID& locale); | 
					
						
							| 
									
										
										
										
											2021-09-10 11:04:54 -04:00
										 |  |  | bool is_well_formed_currency_code(StringView currency); | 
					
						
							|  |  |  | bool is_well_formed_unit_identifier(StringView unit_identifier); | 
					
						
							| 
									
										
										
										
											2021-08-24 22:58:45 -04:00
										 |  |  | Vector<String> canonicalize_locale_list(GlobalObject&, Value locales); | 
					
						
							| 
									
										
										
										
											2021-09-05 15:27:11 -04:00
										 |  |  | Optional<String> best_available_locale(StringView const& locale); | 
					
						
							| 
									
										
										
										
											2021-09-11 07:58:33 -04:00
										 |  |  | String insert_unicode_extension_and_canonicalize(Unicode::LocaleID locale_id, Unicode::LocaleExtension extension); | 
					
						
							|  |  |  | LocaleResult resolve_locale(Vector<String> const& requested_locales, LocaleOptions const& options, Vector<StringView> const& relevant_extension_keys); | 
					
						
							| 
									
										
										
										
											2021-09-04 17:08:57 +01:00
										 |  |  | Vector<String> lookup_supported_locales(Vector<String> const& requested_locales); | 
					
						
							| 
									
										
										
										
											2021-09-11 07:58:33 -04:00
										 |  |  | Vector<String> best_fit_supported_locales(Vector<String> const& requested_locales); | 
					
						
							| 
									
										
										
										
											2021-09-04 17:08:57 +01:00
										 |  |  | Array* supported_locales(GlobalObject&, Vector<String> const& requested_locales, Value options); | 
					
						
							| 
									
										
										
										
											2021-09-01 22:08:15 -04:00
										 |  |  | Object* coerce_options_to_object(GlobalObject& global_object, Value options); | 
					
						
							| 
									
										
										
										
											2021-09-11 08:24:17 -04:00
										 |  |  | Value get_option(GlobalObject& global_object, Object const& options, PropertyName const& property, Value::Type type, Vector<StringView> const& values, Fallback fallback); | 
					
						
							| 
									
										
										
										
											2021-09-10 11:04:54 -04:00
										 |  |  | Optional<int> default_number_option(GlobalObject& global_object, Value value, int minimum, int maximum, Optional<int> fallback); | 
					
						
							| 
									
										
										
										
											2021-09-11 08:38:57 -04:00
										 |  |  | Optional<int> get_number_option(GlobalObject& global_object, Object const& options, PropertyName const& property, int minimum, int maximum, Optional<int> fallback); | 
					
						
							| 
									
										
										
										
											2021-09-06 14:37:23 -04:00
										 |  |  | Vector<PatternPartition> partition_pattern(StringView pattern); | 
					
						
							| 
									
										
										
										
											2021-08-24 22:58:45 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | } |