Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

Commit a6b1c42

Browse files
committed
(start of) add copyright when rebuilding locale-data
1 parent d356082 commit a6b1c42

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ data found at http://www.unicode.org/cldr/data/. See the `LICENSE.txt` file
9696
accompanying this software for terms of use.
9797

9898

99+
### Rebuilding
100+
101+
* Visit http://cldr.unicode.org/index/downloads and choose a version, for example http://unicode.org/Public/cldr/23.1/.
102+
* Download `core.zip` and `tools.zip` to a folder/directory.
103+
* Unzip the zip files.
104+
* Run `node tools/Ldml2Json.js <folder>/tools` where `<folder>` is the location where you downloaded the zip files.
105+
* TOOD... next steps...
106+
107+
99108
## License
100109

101110
Copyright (c) 2013 Andy Earnshaw

tools/Ldml2Json.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ var
1717
spawn = require('child_process').spawn,
1818
fs = require('fs'),
1919

20+
copyright = 'This file is a modified form of the Unicode CLDR data found at http://www.unicode.org/cldr/data/.\n\nCOPYRIGHT AND PERMISSION NOTICE\n\nCopyright (c) 1991-2013 Unicode, Inc. All rights reserved. Distributed under the Terms of Use in http://www.unicode.org/copyright.html.',
21+
copyrightJsonp = '/' + '*\n' + copyright + '\n*' + '/\n',
22+
2023
// The 'callback' function for the JSONP files
2124
jsonpFn = 'Intl.__addLocaleData',
2225

@@ -126,7 +129,7 @@ function cldrToIntl() {
126129
base;
127130

128131
locales.forEach(function (dir) {
129-
var json, obj;
132+
var json, obj, objCopy;
130133

131134
// The Ldml2JsonConverter tool creats directories even for locales that have
132135
// no data that we require
@@ -151,10 +154,14 @@ function cldrToIntl() {
151154
// Process our object into a format that can easily be parsed by Intl.js
152155
obj = processObj(obj);
153156

157+
// We only want to embed the copyright in the json file (not jsonp).
158+
objCopy = JSON.parse(JSON.stringify(obj));
159+
objCopy.COPYRIGHT = copyright;
160+
154161
process.stdout.write('\r\x1b[K\r\tWriting locale-data/json/'+ dir +'.json');
155-
fs.writeFileSync('locale-data/json/'+ dir +'.json', JSON.stringify(obj, null, 4));
162+
fs.writeFileSync('locale-data/json/'+ dir +'.json', JSON.stringify(objCopy, null, 4));
156163

157-
var jsonp = jsonpFn
164+
var jsonp = copyrightJsonp + jsonpFn
158165
+ '('
159166
+ JSON.stringify(obj).replace(jsonpExp, '$1:')
160167
+ ')';

0 commit comments

Comments
 (0)