Add option to regenerate i18n, add make target for it, move stuff around, cleanup

This commit is contained in:
su-ex 2021-05-29 15:07:59 +02:00
parent c18cc22db7
commit f980cef006
No known key found for this signature in database
GPG Key ID: E9E9F6644110943E
4 changed files with 82 additions and 43 deletions

View File

@ -1,10 +1,10 @@
.PHONY: all setup reskindex web desktop desktop-common linux debian pacman local-pkgbuild local-pkgbuild-install windows windows-portable
.PHONY: web-release debian-release pacman-release windows-setup-release windows-unpacked-release windows-portable-release windows-release release
.PHONY: all setup regenerate-i18n reskindex web desktop-common linux debian pacman local-pkgbuild local-pkgbuild-install windows windows-portable
.PHONY: web-release debian-release pacman-release windows-setup-release windows-unpacked-release windows-portable-release windows-release
.PHONY: clean
CFGDIR ?= configs/sc
all: release
all: web
YARN ?= yarnpkg
@ -37,7 +37,9 @@ CURRENT_RELEASE_DIR := $(RELEASE_DIR)/$(VERSION)
setup:
if [ ! -L "element-desktop/webapp" ]; then ./setup.sh; fi
cp $(CFGDIR)/config.json element-web/
regenerate-i18n: setup
./regenerate_i18n.sh
reskindex: setup
$(YARN) --cwd matrix-react-sdk reskindex
@ -45,6 +47,7 @@ reskindex: setup
web: export DIST_VERSION=$(WEB_OUT_DIST_VERSION)
web: setup reskindex
cp $(CFGDIR)/config.json element-web/
$(YARN) --cwd element-web dist
echo "$(VERSION)" > element-web/webapp/version
@ -52,8 +55,6 @@ desktop-common: web
$(YARN) --cwd element-desktop run fetch --cfgdir ''
$(YARN) --cwd element-desktop run build:native
desktop: windows linux
linux: desktop-common
$(YARN) --cwd element-desktop run build64linux
@ -114,8 +115,6 @@ macos-release: macos
mkdir -p $(CURRENT_RELEASE_DIR)
cp $(OUT_MACOS) $(CURRENT_RELEASE_DIR)
release: web-release debian-release pacman-release windows-release
clean:
$(YARN) --cwd matrix-js-sdk clean
$(YARN) --cwd matrix-react-sdk clean

View File

@ -2,6 +2,10 @@
SCHILDI_ROOT="$(dirname "$(realpath "$0")")"
i18n_helper_path="$SCHILDI_ROOT/i18n-helper/index.js"
i18n_path="src/i18n/strings"
i18n_overlay_path="$SCHILDI_ROOT/i18n-overlays"
add_upstream() {
if git remote | grep -q upstream; then
echo "Remote named upstream already exists!"
@ -64,9 +68,13 @@ check_clean_git() {
revert_i18n_changes() {
local i18n_path="$1"
local skip_commit="$2"
git checkout upstream/master -- "$i18n_path"
git commit -m "Automatic i18n reversion" || true
if [[ "$skip_commit" != [Yy]* ]]; then
git commit -m "Automatic i18n reversion" || true
fi
}
apply_i18n_changes() {
@ -75,3 +83,36 @@ apply_i18n_changes() {
git add "$i18n_path"
git commit -m "Automatic i18n adjustment" || true
}
automatic_i18n_reversion() {
local skip_commit="$1"
pushd "$SCHILDI_ROOT/matrix-react-sdk" > /dev/null
revert_i18n_changes "$i18n_path" $skip_commit
popd > /dev/null
pushd "$SCHILDI_ROOT/element-web" > /dev/null
revert_i18n_changes "$i18n_path" $skip_commit
popd > /dev/null
pushd "$SCHILDI_ROOT/element-desktop" > /dev/null
revert_i18n_changes "$i18n_path" $skip_commit
popd > /dev/null
}
automatic_i18n_adjustment() {
node "$i18n_helper_path" "$SCHILDI_ROOT/matrix-react-sdk/$i18n_path" "$i18n_overlay_path/matrix-react-sdk"
pushd "$SCHILDI_ROOT/matrix-react-sdk" > /dev/null
apply_i18n_changes "$i18n_path"
popd > /dev/null
node "$i18n_helper_path" "$SCHILDI_ROOT/element-web/$i18n_path" "$i18n_overlay_path/element-web"
pushd "$SCHILDI_ROOT/element-web" > /dev/null
apply_i18n_changes "$i18n_path"
popd > /dev/null
node "$i18n_helper_path" "$SCHILDI_ROOT/element-desktop/$i18n_path" "$i18n_overlay_path/element-desktop"
pushd "$SCHILDI_ROOT/element-desktop" > /dev/null
apply_i18n_changes "$i18n_path"
popd > /dev/null
}

View File

@ -5,60 +5,34 @@ set -e
mydir="$(dirname "$(realpath "$0")")"
branch=${BRANCH:-"sc"}
i18n_helper="node i18n-helper/index.js"
i18n_path="src/i18n/strings"
i18n_overlay_path="i18n-overlays"
pushd "$mydir" > /dev/null
source ./merge_helpers.sh
# Check branch
check_branch $branch
forall_repos check_branch $branch
# check_clean_git
# Ensure clean git state
forall_repos check_clean_git
# Automatic i18n reversion
pushd "matrix-react-sdk" > /dev/null
revert_i18n_changes "$i18n_path"
popd > /dev/null
pushd "element-web" > /dev/null
revert_i18n_changes "$i18n_path"
popd > /dev/null
pushd "element-desktop" > /dev/null
revert_i18n_changes "$i18n_path"
popd > /dev/null
automatic_i18n_reversion
# Merge
forall_repos git fetch upstream
forall_repos git merge upstream/master
# Refresh environment
make clean
make setup
# Automatic i18n adjustment
$i18n_helper "matrix-react-sdk/$i18n_path" "$i18n_overlay_path/matrix-react-sdk"
pushd "matrix-react-sdk" > /dev/null
apply_i18n_changes "$i18n_path"
popd > /dev/null
$i18n_helper "element-web/$i18n_path" "$i18n_overlay_path/element-web"
pushd "element-web" > /dev/null
apply_i18n_changes "$i18n_path"
popd > /dev/null
$i18n_helper "element-desktop/$i18n_path" "$i18n_overlay_path/element-desktop"
pushd "element-desktop" > /dev/null
apply_i18n_changes "$i18n_path"
popd > /dev/null
automatic_i18n_adjustment
# Automatic theme update
pushd "matrix-react-sdk" > /dev/null
./theme.sh
popd > /dev/null
# Refresh environment
make clean
make setup
popd > /dev/null

25
regenerate_i18n.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
set -e
mydir="$(dirname "$(realpath "$0")")"
branch=${BRANCH:-"sc"}
pushd "$mydir" > /dev/null
source ./merge_helpers.sh
# Check branch
check_branch $branch
forall_repos check_branch $branch
# Ensure clean git state
forall_repos check_clean_git
# Automatic i18n reversion
automatic_i18n_reversion y
# Automatic i18n adjustment
automatic_i18n_adjustment
popd > /dev/null