From 9a50eaaafe1332a75bd40ec463a599b3c7fae67c Mon Sep 17 00:00:00 2001 From: Jaro Date: Sun, 12 Mar 2023 12:17:12 +0100 Subject: [PATCH] Clarify spanLanguage and add basic ICU conversion. --- src/Data/Text/ParagraphLayout/Internal/Plain.hs | 5 +++-- src/Data/Text/ParagraphLayout/Internal/Span.hs | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Data/Text/ParagraphLayout/Internal/Plain.hs b/src/Data/Text/ParagraphLayout/Internal/Plain.hs index ad09ba1..1a488f2 100644 --- a/src/Data/Text/ParagraphLayout/Internal/Plain.hs +++ b/src/Data/Text/ParagraphLayout/Internal/Plain.hs @@ -263,6 +263,7 @@ runBreaksFromSpan run spanBreaks = isEndSpace :: Char -> Bool isEndSpace c = c `elem` [' ', '\t', '\x1680'] --- TODO: Identify and correct for differences between the two. +-- TODO: Convert from IETF BCP 47 language tag to ICU locale identifier, +-- possibly with an algorithm to find the best matching available locale. localeFromLanguage :: String -> LocaleName -localeFromLanguage x = Locale x +localeFromLanguage x = Locale $ map (\c -> if c == '-' then '_' else c) x diff --git a/src/Data/Text/ParagraphLayout/Internal/Span.hs b/src/Data/Text/ParagraphLayout/Internal/Span.hs index 438e025..21441be 100644 --- a/src/Data/Text/ParagraphLayout/Internal/Span.hs +++ b/src/Data/Text/ParagraphLayout/Internal/Span.hs @@ -30,7 +30,9 @@ data Span = Span data SpanOptions = SpanOptions { spanLanguage :: String - -- ^ Used for selecting the appropriate glyphs and line breaking rules. + -- ^ IETF BCP 47 language tag, such as the value expected to be found in + -- the HTML @lang@ attribute. + -- Used for selecting the appropriate glyphs and line breaking rules. } deriving (Eq, Read, Show) -- 2.30.2