Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wotwizard-ui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
wotwizard-ui
Commits
7729b0c4
Commit
7729b0c4
authored
3 years ago
by
CaTasTrOOf
Browse files
Options
Downloads
Patches
Plain Diff
Add pre-commit hook to check i18n keys
parent
af98066e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.githooks/pre-commit
+9
-0
9 additions, 0 deletions
.githooks/pre-commit
.gitignore
+4
-0
4 additions, 0 deletions
.gitignore
utils/findMissingI18nKeys.sh
+45
-0
45 additions, 0 deletions
utils/findMissingI18nKeys.sh
with
58 additions
and
0 deletions
.githooks/pre-commit
0 → 100755
+
9
−
0
View file @
7729b0c4
#!/bin/sh
$(
git rev-parse
--show-toplevel
)
/utils/findMissingI18nKeys.sh
FINDING_MISSING_KEYS
=
$?
if
[
$FINDING_MISSING_KEYS
-ne
0
]
;
then
echo
"You must to complete all i18n keys used in pages"
exit
$FINDING_MISSING_KEYS
fi
exit
0
This diff is collapsed.
Click to expand it.
.gitignore
+
4
−
0
View file @
7729b0c4
...
...
@@ -89,3 +89,7 @@ sw.*
# Vim swap files
*.swp
# Script generated files
*.missing
keysUsed
\ No newline at end of file
This diff is collapsed.
Click to expand it.
utils/findMissingI18nKeys.sh
0 → 100755
+
45
−
0
View file @
7729b0c4
#!/bin/sh
TMP_FILE
=
temp
KEY_FILE
=
keysUsed
grep
--include
=
\*
.vue
--exclude
=
\*
template.vue
-roE
-e
"
\\\$
(t|tc)
\(
(
\"
|')([a-Z.]*)(
\"
|')(, [a-Z._]*){0,1}
\)
"
.
>
$TMP_FILE
sed
-i
-e
"s/'/
\"
/"
$TMP_FILE
sed
-i
-e
"s/'/
\"
/"
$TMP_FILE
sed
-i
-E
-e
's/\..*:\$(t|tc)\("([a-Z.]*).*$/\2/'
$TMP_FILE
sort
$TMP_FILE
|
uniq
>
$KEY_FILE
FILES
=
"i18n/locales/*.json"
for
f
in
$FILES
do
echo
"Processing
$f
file..."
missingFile
=
"
$(
basename
$f
)
.missing"
if
[
-f
$missingFile
]
then
rm
-fr
$missingFile
fi
while
read
key
;
do
jq
-e
".
$key
"
<
$f
>
/dev/null
status
=
$?
if
[
$status
-ne
0
]
then
echo
$key
>>
$missingFile
fi
done
<
$KEY_FILE
# take action on each file. $f store current file name
# cat "$f"
done
MISSING_FILES
=
"*.missing"
RETURN_CODE
=
0
if
ls
$MISSING_FILES
1> /dev/null 2>&1
;
then
for
f
in
$MISSING_FILES
do
RETURN_CODE
=
$((
RETURN_CODE+1
))
echo
"Missing keys in
$f
"
cat
$f
done
fi
rm
$KEY_FILE
$TMP_FILE
exit
$RETURN_CODE
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