CLDRModify using Config file

The CLDRModify tool can be used to make changes to a number of files, based on a configuration file.

As an example of how this is done, and the results, see: [TODO ADD EXAMPLE]

File Format

The file format is a series of lines of the form:

ConfigKeys1=ConfigMatch1 ; ConfigKeys2=ConfigMatch2 ; …

Debugging

The following line shows the number of file lines that are applicable to this locale. It may be helpful in debugging.

# Checking entries & adding: 2

You can also search for /fixList.add(‘k’,/ in the file, and put a breakpoint in handleStart or handlePath.

ConfigKeys

locale, action, path, value, new_path, new_value, draft

A locale (regex) must be present.

Not all of {path, value, new_path, new_value} will be present (or can be), depending on the action.

ConfigMatch

For the action, see below. Everything else can be a regex or an exact string.

// Use a string of “/…/” for a regex match, otherwise an action, otherwise an exact string match.

// The regex match is a “find”, so use /^…$/ for a whole string match.

If the locale is /./, then any locale matches.

Warning! This won’t work if you need certain literal characters (such as ; or a leading or trailing space, etc.). See TODO

ConfigAction

action=delete

If there is a match for the value and path and locale, then the action is taken.

If the path is empty, any path matches. If the value is empty, any value matches.

action=add

The new_path and new_value are explicit strings, and the <new_path, new_value> are added to the files that match the locale.

action=addNew

Same as add, but only for paths that don’t have values in the original value.

action=replace

Replace <path, value> with <newPath, newValue>

action=copy

Add <newPath> with any values at paths matched by <path>. If draft is set, draft status will be draft.

Example:

# CLDR-19394 copy Off/On from "ss" to the new typeValues (as unconfirmed)
locale=/^.*/ ; action=copy ; path=//ldml/localeDisplayNames/types/type[@key="ss"][@type="none"][@scope="core"] ; new_path=//ldml/localeDisplayNames/typeValues/typeValue[@type="no"] ; draft=unconfirmed
locale=/^.*/ ; action=copy ; path=//ldml/localeDisplayNames/types/type[@key="ss"][@type="standard"][@scope="core"] ; new_path=//ldml/localeDisplayNames/typeValues/typeValue[@type="yes"] ; draft=unconfirmed

If path begins with /^ then it is a regex match, and new_path can contain replacement values such as $0$9

action=copyNew

Same as copy but only for paths that don’t have values in the original value.

Example:

# CLDR-19640 copy 'other' to 'many' for certain locales.
locale=/^(ca|es|fr|it|pt|pt_PT)$/ ; action=copyNew ; path=/^(.*)[@count="other"](.*)$/ ; new_path=$1[@count="many"]$2 ; draft=unconfirmed

Example file

locale= sv ; action=delete; value= YER ; path= //ldml/numbers/currencies/currency[@type=”YER”]/symbol ;

locale=en ; action=delete ; path=/.*short.*/

locale=en ; action=add ; new_path=//ldml/localeDisplayNames/territories/territory[@type=”PS”][@alt=”short”] ; new_value=Palestine

Path Ids

An exact path can be either the literal string or a hex id. So the following are equivalent:

locale= sk ; action=add ; new_path=68e706b7c7873181 ; new_value=honduraskej lempiry

locale= sk ; action=add ; new_path=//ldml/numbers/currencies/currency[@type=”HNL”]/displayName[@count=”many”] ; new_value=honduraskej lempiry

TODO

Change add so that path and/or value can be present, and if so, $0..$9 will be substituted for in the respective new_path or new_value.

After splitting at “;”, change \x3B and other \x{H..H} characters into “;”.