ProposalIntroduce new syntax, as follows. By default, auto-detect from the message pattern string whether it uses the old syntax or the new one.
ICU ticket: http://bugs.icu-project.org/trac/ticket/9333 "more robust MessageFormat syntax" ExampleWith ApostropheMode.DOUBLE_OPTIONAL (ICU 4.8 default behavior): In folder { folder_name} on {when, date, yyyy-MM-dd} there are { num1, choice, 1<very few|4#at least four} files including {num2, plural, offset:1 =0 {no} =1 {one} =2 {two} text files from {gender, select, female {her} male{his}other{their}} collection.
With ApostropheMode.SINGLE_AND_DIGRAPH_BRACES (proposed ICU 50 behavior): In folder {| folder_name|} on {|when, date, yyyy-MM-dd|} there are {| num1, choice, 1< {|very few|} 4# {|at least four|}|} files including {|num2, plural, offset:1 =0 {|no|} =1 {|one|} =2 {|two|} text files from {|gender, select, female {|her|} male{|his|}other{|their|}|} collection. Problems with old syntax
Examples
Minor IssueIn some translation tools, it has been awkward to have sub-messages enclosed in {pairs of curly braces}. It would be slightly easier for those tools to instead terminate sub-messages at the next syntax token. On the other hand, the {pairs} are useful for avoiding white space characters when a message is broken into lines without enclosing each line in "quotes" or similar. (White space (line feeds, indentation) are not an issue in C++ or Java when messages are written in "string literals", but can be awkward if messages are in XML contents or similar.) Ideas
Sample: All-ASCII syntax, bracketing selectorsWhen selectors are bracketed, then a sub-message is terminated either by another selector or by the end-of-argument token. Choice format selectors: {:1<:} for an exclusive limit (sub-message for values greater than 1) vs. {:4:} for an inclusive limit (sub-message for values greater than or equal to 4). Plural format selectors: We could distinguish explicit values vs. keywords by looking for a leading digit (although ICU 4.8 allows any non-syntax, non-whitespace character in keywords), adding syntax inside the selector, or using different selector begin-end tokens. This sample adds an equals sign inside the explicit-value selector, similar to the ICU 4.8 syntax. In folder {@folder_name@} on {@when, date, yyyy-MM-dd@} there are {@num1, choice, {:1<:}very few{:4:}at least four@} files including {@num2, plural, offset:1 {:=0:}no{:=1:}one{:=2:}two{+} {@gender, select, {:female:}her{:male:}his{:other:}their {'@'}{'}'}@} collection. Sample: Syntax with Latin-1, bracketing sub-messagesSub-messages are {§bracketed like this§}. No syntax for "end sub-message" or "ignore following white space". Choice format selectors: 1< for an exclusive limit (sub-message for values greater than 1) vs. 4 for an inclusive limit (sub-message for values greater than or equal to 4). In folder { °folder_name °} on {°when, date, yyyy-MM-dd °} there are { °num1, choice, 1< {«very few»} 4 {«at least four»} °} files including { °num2, plural, offset:1 =0 {«no»} =1 {«one»} =2 {«two»} °} text files from { °gender, select, female {«her»} male{«his»}other{«their {¦§¦}{¦}¦}»} °} collection. Same idea, different characters, no quoting/escaping syntax: In folder «% folder_name%» on «%when, date, yyyy-MM-dd %» there are «% num1, choice, 1< «{very few}» 4 «{at least four}»%» files including «%num2, plural, offset:1 =0 «{no}» =1 «{one}» =2 «{two}» text files from «%gender, select, female «{her}» male«{his}»other«{their %#}»%» collection. Sub-messages are ~+{bracketed like this}+~. No syntax for "ignore following white space". No syntax for quoting/escaping in this sample. Needed? Maybe ~%{}%~ as a new-syntax marker and trigraph breaker with no output by itself? Choice format selectors: 1< for an exclusive limit (sub-message for values greater than 1) vs. 4 for an inclusive limit (sub-message for values greater than or equal to 4). In folder ~%{ folder_name }%~ on ~%{when, date, yyyy-MM-dd }%~ there are ~%{ num1, choice, 1< ~+{very few}+~ 4 ~+{at least four}+~ }%~ files including ~%{ num2, plural, offset:1 =0 ~+{no}+~ =1 ~+{one}+~ =2 ~+{two}+~ }%~ text files from ~%{ gender, select, female ~+{her}+~ male~+{his}+~other~+{their xyz}+~ }%~ collection. Sample: Somewhat XML-ishArgument is one of
where PWS=Pattern_White_Space. Sub-message begins with No syntax for quoting/escaping; needed? Maybe optional In folder {arg folder_name/} on {arg when:date}yyyy-MM-dd{/arg} there are {arg num1:choice}{msg 1<}very few{/msg}{msg 4<=}at least four{/msg}{/arg} files including {arg num2:plural}{offset:1}{msg =0}no{/msg}{msg =1}one{/msg}{msg =2}two{/msg} {msg other}one and {plural_number/} from group #3{/msg}{/arg} text files from {arg gender:select}{msg female}her{/msg}{msg male}his{/msg}{msg other}their xyz{/msg}{/arg} collection. Original SampleIn folder {$folder_name$} on {$when, date, yyyy-MM-dd$} there are {$num1, choice, {<1}very few{<=4}at least four$} files including {$num2, plural, offset:1 {=0}no{=1}one{=2}two{+} {$gender, select, {:female}her{:male}his{:other}their {'$'}{'$'}$} collection. Mark's comments on the original version & sampleSome thoughts on alternatives. {%folder_name%} or {!folder_name!} or {$folder_name$} {:0:} {<1>} {#} {'<any char>'} Also, we could use {% or to trigger new vs old syntax, and then have the same method.... |