1# Path Transformations 2 3# see LdmlConvertRule.java 4 5# * Some special transformation, like add an additional layer, can be easily 6# * done by transforming the path. Following rules covers these kind of 7# * transformation. 8# * Note: It is important to keep the order for these rules. Whenever a 9# * rule matches, further rules won't be applied. 10# 11# Syntax: 12# 13# # line comment 14# < match pattern 15# > replacement pattern 16# 17 18# separate them to two layers. 19< (.*ldml/exemplarCharacters)\[@type="([^"]*)"\](.*) 20> $1/$2$3 21 22# Add "standard" as type attribute to exemplarCharacter element if there is none 23< (.*ldml/exemplarCharacters)(.*)$ 24> $1/standard$2 25 26## (Note: CLDR version is added in code) 27 28# Transform underscore to hyphen-minus in language keys 29# Does not produce valid bcp47, see Ldml2JsonConverter.fixXpathBcp47() 30< (.*/language\[@type="[a-z]{2,3})_([^"]*"\](\[@alt="short"])?) 31> $1-$2 32 33# Separate "ellipsis" from its type as another layer. 34< (.*/ellipsis)\[@type="([^"]*)"\](.*)$ 35> $1/$2$3 36 37# move datetimeSkeleton to a parallel path 38< (.*/calendars)/calendar\[@type="([^"]*)"\](.*)Length\[@type="([^"]*)"\]/(date|time|dateTime)Format\[@type="([^"]*)"\]/(datetimeSkeleton)(.*) 39> $1/$2/$5Skeletons/$4$8 40 41# Remove unnecessary dateFormat/pattern standard-standard 42< (.*/calendars)/calendar\[@type="([^"]*)"\](.*)Length\[@type="([^"]*)"\]/(date|time|dateTime)Format\[@type="(standard)"\]/pattern\[@type="(standard)"\](.*) 43> $1/$2/$5Formats/$4$8 44 45# Remove unnecessary dateFormat/pattern 46< (.*/calendars)/calendar\[@type="([^"]*)"\](.*)Length\[@type="([^"]*)"\]/(date|time|dateTime)Format\[@type="([^"]*)"\]/pattern\[@type="([^"]*)"\](.*) 47> $1/$2/$5Formats-$6/$7/$4$8 48 49# Separate calendar type 50< (.*/calendars)/calendar\[@type="([^"]*)"\](.*)$ 51> $1/$2$3 52 53# Separate "metazone" from its type as another layer 54< (.*/metazone)\[@type="([^"]*)"\]/(.*)$ 55> $1/$2/$3 56 57# Split out types into its various fields 58< (.*)/types/type\[@key="([^"]*)"\]\[@type="([^"]*)"\](.*)$ 59> $1/types/$2/$3$4 60 61# Typographic 62< (.*)/(typographicNames)/(axisName|featureName)\[@type="([^"]*)"\](.*)$ 63> $1/$2/$3s/$4$5 64 65# Typographic 66< (.*)/(typographicNames)/(styleName)(.*)$ 67> $1/$2/$3s/$3$4 68 69# put CharacterLabelPatterns under CharacterLabelPatterns 70< (.*)/(characterLabels)/(characterLabelPattern)(.*)$ 71> $1/characterLabelPatterns/$3$4 72 73# add currency with alt 74< (.*/numbers/currencyFormats\[@numberSystem="([^"]*)"\])/currencyFormatLength/currencyFormat\[@type="(accounting|standard)"]/pattern\[@type="standard"\]\[@alt="([^"]*)"\]$ 75> $1/$3-$4 76 77# add currency without alt 78< (.*/numbers/currencyFormats\[@numberSystem="([^"]*)"\])/currencyFormatLength/currencyFormat\[@type="(accounting|standard)"]/pattern\[@type="standard"\]$ 79> $1/$3 80 81# add type=standard 82< (.*/numbers/(decimal|scientific|percent|currency)Formats\[@numberSystem="([^"]*)"\])/(decimal|scientific|percent|currency)FormatLength/(decimal|scientific|percent|currency)Format\[@type="standard"]/pattern.*$ 83> $1/standard 84 85# Add "type" attribute with value "standard" if there is no "type" in "decimalFormatLength". 86< (.*/numbers/(decimal|scientific|percent)Formats\[@numberSystem="([^"]*)"\]/(decimal|scientific|percent)FormatLength)/(.*)$ 87> $1[@type="standard"]/$5 88 89# 90< (.*/listPattern)/(.*)$ 91> $1[@type="standard"]/$2 92 93# 94< (.*/languagePopulation)\[@type="([^"]*)"\](.*) 95> $1/$2$3 96 97# 98< (.*/languageAlias)\[@type="([^"]*)"\](.*) 99> $1/$2$3 100 101# 102< (.*/scriptAlias)\[@type="([^"]*)"\](.*) 103> $1/$2$3 104 105# 106< (.*/territoryAlias)\[@type="([^"]*)"\](.*) 107> $1/$2$3 108 109# 110< (.*/subdivisionAlias)\[@type="([^"]*)"\](.*) 111> $1/$2$3 112 113# 114< (.*/variantAlias)\[@type="([^"]*)"\](.*) 115> $1/$2$3 116 117# 118< (.*/zoneAlias)\[@type="([^"]*)"\](.*) 119> $1/$2$3 120 121# 122< (.*/alias)(.*) 123> $1/alias$2 124 125# 126< (.*currencyData/region)(.*) 127> $1/region$2 128 129# Skip exemplar city in /etc/GMT or UTC timezones, since they don't have them 130< (.*(GMT|UTC).*/exemplarCity)(.*) 131> 132 133# 134< (.*/transforms/transform[^/]*)/(.*) 135> $1/tRules/$2 136 137# 138< (.*)\[@territories="([^"]*)"\](.*)\[@alt="variant"\](.*) 139> $1\[@territories="$2-alt-variant"\] 140 141# 142< (.*)/weekData/(.*)\[@alt="variant"\](.*) 143> $1/weekData/$2$3 144 145# Annotations: If there is a type, move that into a sibling value 146< (.*)/(annotations)/(annotation)\[@cp="([^"]*)"\]\[@type="([^"]*)"\](.*)$ 147> $1/$2/$4/$5$6 148 149# Annotations: If there is a type, move that into a sibling value 150< (.*)/(annotations)/(annotation)\[@cp="([^"]*)"\](.*)$ 151> $1/$2/$4/default$5 152 153# Grammar : put grammaticalGender into a separate section 154#< (.*)/(grammaticalData)/(.*)/(grammaticalGender)(.*)$ 155#> $1/grammaticalGenderData/$3/$4$5 156 157# BCP47 (No extension, assume 'u') 158< (.*)/(keyword)/(key)\[@name="([^"]*)"\](.*)$ 159> $1/$2/u/$4$5 160 161# BCP47 (Some other extension) 162< (.*)/(keyword)/(key)\[@extension="([^"]*)"\]\[@name="([^"]*)"\](.*)$ 163> $1/$2/$4/$5$6 164 165# PersonNames - name patterns 166< (.*/personName)\[@order="([^"]*)"\]\[@length="([^"]*)"\]\[@usage="([^"]*)"\]\[@formality="([^"]*)"\](.*)/namePattern(.*)$ 167> $1/$2/$3/$4/$5$6$7 168 169# PersonNames - sample names 170< (.*/personNames)/(sampleName)\[@item="([^"]*)"\]/nameField\[@type="([^"]*)"\]$ 171> $1/$2/$3/$4 172 173# ParentLocales 174< (.*/parentLocales)\[@component="([^"]*)"\]/(parentLocale)(.*)$ 175> $1/$2$4 176