Skip to content

Commit dbb4840

Browse files
authored
Merge pull request #24373 from tengqm/lsync-util
Add a util script for localization team
2 parents 56a4d9b + 71f0a9f commit dbb4840

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

scripts/lsync.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
#
3+
# This script checks if the English version of a page has changed since a localized
4+
# page has been committed.
5+
6+
if [ "$#" -ne 1 ] || ! [ -f "$1" ]; then
7+
echo -e "\nThis script checks if the English version of a page has changed since a "
8+
echo -e "localized page has been committed.\n"
9+
echo -e "Usage:\n\t$0 <PATH>\n" >&2
10+
echo -e "Example:\n\t$0 content/zh/docs/concepts/_index.md\n" >&2
11+
exit 1
12+
fi
13+
14+
LOCALIZED="$1"
15+
16+
# Try get the English version
17+
EN_VERSION=`echo $LOCALIZED | sed "s/content\/..\//content\/en\//g"`
18+
if ! [ -f $EN_VERSION ]; then
19+
echo "$EN_VERSION has been removed."
20+
exit 2
21+
fi
22+
23+
# Last commit for the localized file
24+
LASTCOMMIT=`git log -n 1 --pretty=format:%h -- $LOCALIZED`
25+
26+
git diff $LASTCOMMIT...HEAD $EN_VERSION
27+
28+
if [ "$?" -eq 0 ]; then
29+
echo "$LOCALIZED is still in sync"
30+
exit 3
31+
fi

0 commit comments

Comments
 (0)