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
aa5c1531
Commit
aa5c1531
authored
3 years ago
by
CaTasTrOOf
Browse files
Options
Downloads
Patches
Plain Diff
Modification pre-commit Hook
* Fix regex bug * Create missing keys on i18n files
parent
a903472d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.githooks/pre-commit
+1
-1
1 addition, 1 deletion
.githooks/pre-commit
utils/findMissingI18nKeys.sh
+16
-21
16 additions, 21 deletions
utils/findMissingI18nKeys.sh
with
17 additions
and
22 deletions
.githooks/pre-commit
+
1
−
1
View file @
aa5c1531
#!/bin/sh
#!/bin/
ba
sh
$(
git rev-parse
--show-toplevel
)
/utils/findMissingI18nKeys.sh
$(
git rev-parse
--show-toplevel
)
/utils/findMissingI18nKeys.sh
FINDING_MISSING_KEYS
=
$?
FINDING_MISSING_KEYS
=
$?
...
...
This diff is collapsed.
Click to expand it.
utils/findMissingI18nKeys.sh
+
16
−
21
View file @
aa5c1531
#!/bin/sh
#!/bin/
ba
sh
TMP_FILE
=
temp
TMP_FILE
=
temp
KEY_FILE
=
keysUsed
KEY_FILE
=
keysUsed
grep
--include
=
\*
.vue
--exclude
=
\*
template.vue
-roE
-e
"
\\\$
(t|tc)
\(
(
\"
|')([a-Z.]*)(
\"
|')(, [a-Z._]*){0,1}
\)
"
.
>
$TMP_FILE
# Get all used keys in Vue files
grep
--include
=
\*
.vue
--exclude
=
\*
template.vue
-roE
-e
"
\\\$
(t|tc)
\(
(
\"
|')([a-zA-Z.]*)(
\"
|')(, [a-zA-Z._]*){0,1}
\)
"
.
>
$TMP_FILE
sed
-i
-e
"s/'/
\"
/"
$TMP_FILE
sed
-i
-e
"s/'/
\"
/"
$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
sed
-i
-E
-e
's/\..*:\$(t|tc)\("([a-
zA-
Z.]*).*$/\2/'
$TMP_FILE
# Remove duplicates keys
sort
$TMP_FILE
|
uniq
>
$KEY_FILE
sort
$TMP_FILE
|
uniq
>
$KEY_FILE
# Verify all i18n files
FILES
=
"i18n/locales/*.json"
FILES
=
"i18n/locales/*.json"
RETURN_CODE
=
0
for
f
in
$FILES
for
f
in
$FILES
do
do
echo
"Processing
$f
file..."
echo
"Processing
$f
file..."
missingFile
=
"
$(
basename
$f
)
.missing"
if
[
-f
$missingFile
]
tmp
=
$(
mktemp
)
then
rm
-fr
$missingFile
fi
while
read
key
;
do
while
read
key
;
do
# Verify if key exists
jq
-e
".
$key
"
<
$f
>
/dev/null
jq
-e
".
$key
"
<
$f
>
/dev/null
status
=
$?
status
=
$?
# If not, create it
if
[
$status
-ne
0
]
if
[
$status
-ne
0
]
then
then
echo
$key
>>
$missingFile
echo
"create
$key
in file
$f
"
filter
=
".
${
key
}
=
\"
TO_TRANSLATE
\"
"
jq
--sort-keys
"
$filter
"
$f
>
"
$tmp
"
&&
mv
"
$tmp
"
$f
RETURN_CODE
=
$((
RETURN_CODE+1
))
fi
fi
done
<
$KEY_FILE
done
<
$KEY_FILE
# take action on each file. $f store current file name
# cat "$f"
done
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
rm
$KEY_FILE
$TMP_FILE
# Return 0 if no key was created, or number of keys added
exit
$RETURN_CODE
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