Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nghyd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cassiopée
nghyd
Commits
b6e2c2f3
Commit
b6e2c2f3
authored
4 years ago
by
Mathias Chouet
Committed by
mathias.chouet
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add script to check missing translations of JaLHyd messages
parent
11057ede
No related branches found
No related tags found
1 merge request
!82
Resolve "Ajout de la fonctionnalité "Respect des critères""
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/check-translations.js
+44
-0
44 additions, 0 deletions
scripts/check-translations.js
with
44 additions
and
0 deletions
scripts/check-translations.js
0 → 100644
+
44
−
0
View file @
b6e2c2f3
'
use strict
'
;
const
fs
=
require
(
'
fs
'
);
// read and transform JaLHyd message file
const
jalhydMessagesPath
=
"
../jalhyd/src/util/message.ts
"
;
let
jm
=
fs
.
readFileSync
(
jalhydMessagesPath
,
"
utf-8
"
);
// extract enum block
jm
=
jm
.
replace
(
/export enum MessageCode
\{([^
{
]
+
)\}[\s\S]
+/m
,
(
match
,
p1
)
=>
{
return
p1
;
});
// remove comments
jm
=
jm
.
replace
(
/
\/\*[\s\S]
*
?\*\/
/gm
,
""
);
jm
=
jm
.
replace
(
/
\/\/
.+/g
,
""
);
// remove spaces
jm
=
jm
.
replace
(
/
[
\t]
+/g
,
""
);
// remove line breaks
jm
=
jm
.
replace
(
/
\n
/g
,
""
);
// split on ";"
const
messages
=
jm
.
split
(
"
,
"
);
// console.log(messages);
// read every language file
const
localePath
=
"
src/locale
"
;
const
localeDir
=
fs
.
readdirSync
(
localePath
);
for
(
let
i
=
0
;
i
<
localeDir
.
length
;
i
++
)
{
const
localeFile
=
localeDir
[
i
];
const
res
=
localeFile
.
match
(
/^messages
\.([
a-z
]{2})\.
json$/
);
if
(
res
)
{
const
lang
=
res
[
1
];
console
.
log
(
"
Loading translations for language [
"
+
lang
+
"
]
"
);
const
langFilePath
=
localePath
+
'
/
'
+
localeFile
;
let
translations
=
Object
.
keys
(
JSON
.
parse
(
fs
.
readFileSync
(
langFilePath
,
"
utf-8
"
)));
// console.log(translations);
// check against JaLHyd messages list
for
(
const
mess
of
messages
)
{
if
(
!
translations
.
includes
(
mess
))
{
console
.
log
(
"
missing message in [
"
+
lang
+
"
] translation:
"
+
mess
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment