Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
fc834b88
Commit
fc834b88
authored
Nov 09, 2015
by
Matthew Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move scripts to new `lib` folder
Thanks @thisandagain for the tip!
parent
ca102324
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
37 additions
and
23 deletions
+37
-23
Makefile
Makefile
+2
-3
lib/bin/build-locales
lib/bin/build-locales
+4
-4
lib/locale-compare.js
lib/locale-compare.js
+1
-1
test/fixtures/test_es.po
test/fixtures/test_es.po
+0
-0
test/fixtures/test_es_md5map.json
test/fixtures/test_es_md5map.json
+4
-0
test/functional/build_locales_complex_strings.js
test/functional/build_locales_complex_strings.js
+3
-4
test/functional/build_locales_md5map.js
test/functional/build_locales_md5map.js
+16
-0
test/functional/build_locales_mergeTranslations.js
test/functional/build_locales_mergeTranslations.js
+6
-10
test/unit/build_locales_getmd5.js
test/unit/build_locales_getmd5.js
+1
-1
No files found.
Makefile
View file @
fc834b88
...
...
@@ -35,7 +35,7 @@ static:
cp
-a
./static/. ./build/
translations
:
./
src/scripts/buildLocales
/build-locales locales/translations.json
./
lib/bin
/build-locales locales/translations.json
webpack
:
$(WEBPACK)
--bail
...
...
@@ -59,13 +59,12 @@ start:
test
:
@
make lint
@
make build
@
echo
""
@
make unit
@
echo
""
@
make functional
@
echo
""
@
make integration
@
echo
""
lint
:
$(ESLINT)
./
*
.js
...
...
src/scripts/buildLocales
/build-locales
→
lib/bin
/build-locales
View file @
fc834b88
...
...
@@ -10,7 +10,7 @@ var glob = require('glob');
var
path
=
require
(
'
path
'
);
var
po2icu
=
require
(
'
po2icu
'
);
var
helpers
=
require
(
'
./helpers
'
);
var
localeCompare
=
require
(
'
../locale-compare
'
);
// -----------------------------------------------------------------------------
// Main script
...
...
@@ -45,7 +45,7 @@ var icuWithIds = {};
for
(
var
id
in
idsWithICU
)
{
icuWithIds
[
idsWithICU
[
id
]]
=
id
;
}
var
md5WithIds
=
helpers
.
getMD5Map
(
icuWithIds
);
var
md5WithIds
=
localeCompare
.
getMD5Map
(
icuWithIds
);
// Get ui localization strings first
glob
(
poUiDir
+
'
/*
'
,
function
(
err
,
files
)
{
...
...
@@ -59,14 +59,14 @@ glob(poUiDir + '/*', function (err, files) {
var
translations
=
{};
try
{
var
jsTranslations
=
po2icu
.
poFileToICUSync
(
lang
,
jsFile
);
translations
=
helpers
.
mergeNewTranslations
(
translations
,
jsTranslations
,
md5WithIds
);
translations
=
localeCompare
.
mergeNewTranslations
(
translations
,
jsTranslations
,
md5WithIds
);
}
catch
(
err
)
{
process
.
stdout
.
write
(
lang
+
'
:
'
+
err
+
'
\n
'
);
}
try
{
var
pyTranslations
=
po2icu
.
poFileToICUSync
(
lang
,
pyFile
);
translations
=
helpers
.
mergeNewTranslations
(
translations
,
pyTranslations
,
md5WithIds
);
translations
=
localeCompare
.
mergeNewTranslations
(
translations
,
pyTranslations
,
md5WithIds
);
}
catch
(
err
)
{
process
.
stdout
.
write
(
lang
+
'
:
'
+
err
+
'
\n
'
);
}
...
...
src/scripts/buildLocales/helpers
.js
→
lib/locale-compare
.js
View file @
fc834b88
...
...
@@ -46,7 +46,7 @@ Helpers.mergeNewTranslations = function (existingTranslations, newTranslations,
*
* @param {object} idICUMap map where key=icuString, value=react-intl id
*
* @return {objec}
* @return {objec
t
}
*/
Helpers
.
getMD5Map
=
function
(
ICUIdMap
)
{
var
md5Map
=
{};
...
...
test/fixtures/
build_local
es.po
→
test/fixtures/
test_
es.po
View file @
fc834b88
File moved
test/fixtures/test_es_md5map.json
0 → 100644
View file @
fc834b88
{
"2ec20d41b181e1a41c071e13f414a74d"
:
"test.id1"
,
"37ba6d5ef524504215f478912155f9ba"
:
"test.id2"
}
test/
integration/build_locale
s.js
→
test/
functional/build_locales_complex_string
s.js
View file @
fc834b88
...
...
@@ -3,12 +3,11 @@ var path = require('path');
var
po2icu
=
require
(
'
po2icu
'
);
var
tap
=
require
(
'
tap
'
);
var
buildLocales
=
require
(
'
../../
src/scripts/buildLocales/helpers
'
);
var
buildLocales
=
require
(
'
../../
lib/locale-compare
'
);
tap
.
test
(
'
buildLocalesFile
'
,
function
(
t
)
{
var
templates
=
JSON
.
parse
(
fs
.
readFileSync
(
path
.
resolve
(
__dirname
,
'
../fixtures/build_locales.json
'
),
'
utf8
'
));
var
md5map
=
buildLocales
.
getMD5Map
(
templates
);
var
newTranslations
=
po2icu
.
poFileToICUSync
(
'
es
'
,
path
.
resolve
(
__dirname
,
'
../fixtures/build_locales.po
'
));
var
md5map
=
JSON
.
parse
(
fs
.
readFileSync
(
path
.
resolve
(
__dirname
,
'
../fixtures/test_es_md5map.json
'
),
'
utf8
'
));
var
newTranslations
=
po2icu
.
poFileToICUSync
(
'
es
'
,
path
.
resolve
(
__dirname
,
'
../fixtures/test_es.po
'
));
var
translations
=
buildLocales
.
mergeNewTranslations
({},
newTranslations
,
md5map
);
t
.
ok
(
translations
[
'
test.id1
'
]
!==
undefined
);
...
...
test/functional/build_locales_md5map.js
0 → 100644
View file @
fc834b88
var
fs
=
require
(
'
fs
'
);
var
path
=
require
(
'
path
'
);
var
tap
=
require
(
'
tap
'
);
var
buildLocales
=
require
(
'
../../lib/locale-compare
'
);
tap
.
test
(
'
buildLocalesFile
'
,
function
(
t
)
{
var
actualMd5map
=
JSON
.
parse
(
fs
.
readFileSync
(
path
.
resolve
(
__dirname
,
'
../fixtures/test_es_md5map.json
'
),
'
utf8
'
));
var
templates
=
JSON
.
parse
(
fs
.
readFileSync
(
path
.
resolve
(
__dirname
,
'
../fixtures/build_locales.json
'
),
'
utf8
'
));
var
testMd5map
=
buildLocales
.
getMD5Map
(
templates
);
for
(
var
key
in
actualMd5map
)
{
t
.
ok
(
testMd5map
[
key
]
!==
undefined
);
}
t
.
end
();
});
test/functional/build_locales_mergeTranslations.js
View file @
fc834b88
var
crypto
=
require
(
'
crypto
'
);
var
tap
=
require
(
'
tap
'
);
var
buildLocales
=
require
(
'
../../
src/scripts/buildLocales/helpers
'
);
var
buildLocales
=
require
(
'
../../
lib/locale-compare
'
);
tap
.
test
(
'
buildLocalesMergeTranslations
'
,
function
(
t
)
{
var
existingTranslations
=
{
'
test.test1
'
:
'
It
\'
s like raaayaaain, on your wedding day
'
,
'
test.test2
'
:
'
Free to flyyy, when you already paid
'
};
var
md5Test1
=
crypto
.
createHash
(
'
md5
'
).
update
(
existingTranslations
[
'
test.test1
'
],
'
utf8
'
).
digest
(
'
hex
'
);
var
md5Test2
=
crypto
.
createHash
(
'
md5
'
).
update
(
existingTranslations
[
'
test.test2
'
],
'
utf8
'
).
digest
(
'
hex
'
);
var
md5map
=
{};
md5map
[
md5Test1
]
=
'
test.test1
'
;
md5map
[
md5Test2
]
=
'
test.test2
'
;
var
newTranslations
=
{
'
Isn
\'
t it ironic? No.
'
:
'
Es irónico? No.
'
};
var
md5Test3
=
crypto
.
createHash
(
'
md5
'
).
update
(
'
Isn
\'
titironic?No.
'
,
'
utf8
'
).
digest
(
'
hex
'
);
md5map
[
md5Test3
]
=
'
test.test3
'
;
var
md5map
=
{
'
c21ce5ceefe167028182032d4255a384
'
:
'
test.test1
'
,
'
9c40648034e467e16f8d6ae24bd610ab
'
:
'
test.test2
'
,
'
6885a345adafb3a9dd43d9f549430c88
'
:
'
test.test3
'
};
var
mergedTranslations
=
buildLocales
.
mergeNewTranslations
(
existingTranslations
,
newTranslations
,
md5map
);
t
.
ok
(
mergedTranslations
[
'
test.test3
'
]
!==
undefined
);
...
...
test/unit/build_locales_getmd5.js
View file @
fc834b88
var
tap
=
require
(
'
tap
'
);
var
buildLocales
=
require
(
'
../../
src/scripts/buildLocales/helpers
'
);
var
buildLocales
=
require
(
'
../../
lib/locale-compare
'
);
tap
.
test
(
'
buildLocalesGetMD5
'
,
function
(
t
)
{
var
testString1
=
'
are there bears here?
'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment