diff --git a/aio/scripts/build.sh b/aio/scripts/build.sh index 4880b298e3cfdc0af448a2d18f380657f65e2e48..562ee80cc266d9757135069b2f2faa1d3bacbaa9 100755 --- a/aio/scripts/build.sh +++ b/aio/scripts/build.sh @@ -33,14 +33,14 @@ function build::frontend { mkdir -p ${FRONTEND_DIR}/en ${NG_BIN} build --aot --prod --outputPath=${TMP_DIR}/frontend/en - languages=($(ls i18n | awk -F"." '{if (NF>2) print $2}')) + languages=($(find i18n/* -type d|cut -d"/" -f2)) for language in "${languages[@]}"; do mkdir -p ${FRONTEND_DIR}/${language} say "Building frontend for locale: ${language}" ${NG_BIN} build --aot \ --prod \ - --i18nFile=${I18N_DIR}/messages.${language}.xlf \ + --i18nFile=${I18N_DIR}/${language}/messages.${language}.xlf \ --i18nFormat=xlf \ --i18nLocale=${language} --outputPath=${TMP_DIR}/frontend/${language} done diff --git a/aio/scripts/pre-commit-i18n.sh b/aio/scripts/pre-commit-i18n.sh index a00c95953ccc59e120540cb8b174b24a4cf2f591..5110bffb084d2af49ec11c378fe2fffef2fcfa15 100755 --- a/aio/scripts/pre-commit-i18n.sh +++ b/aio/scripts/pre-commit-i18n.sh @@ -22,14 +22,11 @@ ng xi18n --outFile ../i18n/messages.new.xlf MD5_OLD=$(md5sum i18n/messages.xlf | cut -c -32) MD5_NEW=$(md5sum i18n/messages.new.xlf | cut -c -32) -echo $MD5_OLD -echo $MD5_NEW - if [ $MD5_OLD != $MD5_NEW ] ; then - ng xi18n --outFile ../i18n/messages.xlf - xliffmerge + mv i18n/messages.new.xlf i18n/messages.xlf + aio/scripts/xliffmerge.sh echo "i18n/messages.* files are updated. Commit them too." - git add i18n/messages.* + git add i18n fi # Remove extracted file for check diff --git a/aio/scripts/xliffmerge.sh b/aio/scripts/xliffmerge.sh new file mode 100755 index 0000000000000000000000000000000000000000..f63c7ec4aae158890ffd485a7f2633e5593d10e3 --- /dev/null +++ b/aio/scripts/xliffmerge.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Copyright 2019 The Kubernetes Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Collect current localized files +languages=($(find i18n/* -type d|cut -d"/" -f2)) +for language in "${languages[@]}"; do + mv i18n/${language}/messages.${language}.xlf i18n +done + +# Merge generated messages file into localized files. +xliffmerge + +# Deliver merged localized files into each locale directories. +for language in "${languages[@]}"; do + mv i18n/messages.${language}.xlf i18n/${language} +done diff --git a/i18n/fr/OWNERS b/i18n/fr/OWNERS new file mode 100644 index 0000000000000000000000000000000000000000..54c08dee0b2bb15f573f9bac91a450bfb79b90ca --- /dev/null +++ b/i18n/fr/OWNERS @@ -0,0 +1,3 @@ +approvers: + - feloy + diff --git a/i18n/messages.fr.xlf b/i18n/fr/messages.fr.xlf similarity index 100% rename from i18n/messages.fr.xlf rename to i18n/fr/messages.fr.xlf diff --git a/i18n/ja/OWNERS b/i18n/ja/OWNERS new file mode 100644 index 0000000000000000000000000000000000000000..95e3f15ba9a664f4cd8bd2d5c4e5788c3aec22b5 --- /dev/null +++ b/i18n/ja/OWNERS @@ -0,0 +1,3 @@ +approvers: + - shu-mutou + diff --git a/i18n/messages.ja.xlf b/i18n/ja/messages.ja.xlf similarity index 100% rename from i18n/messages.ja.xlf rename to i18n/ja/messages.ja.xlf diff --git a/i18n/ko/OWNERS b/i18n/ko/OWNERS new file mode 100644 index 0000000000000000000000000000000000000000..32020f0f33e1d15d3693ea83c311dbb848ff68eb --- /dev/null +++ b/i18n/ko/OWNERS @@ -0,0 +1,3 @@ +approvers: + - seokho-son + diff --git a/i18n/messages.ko.xlf b/i18n/ko/messages.ko.xlf similarity index 100% rename from i18n/messages.ko.xlf rename to i18n/ko/messages.ko.xlf diff --git a/i18n/messages.zh.xlf b/i18n/zh/messages.zh.xlf similarity index 100% rename from i18n/messages.zh.xlf rename to i18n/zh/messages.zh.xlf diff --git a/package.json b/package.json index 34ca1de1dd5fd6c62e385dcbcdf2cc8a7783c8e0..5626c1f5c8921b45e54df2a6937c423323d34843 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "check:frontend:scss": "./aio/scripts/format.sh --styles --check && ./node_modules/sass-lint/bin/sass-lint.js -c .sass-lint.yml 'src/app/frontend/**/*.scss' -v -q", "check:frontend:html": "./aio/scripts/format.sh --html --check", "check:license": "gulp check-license-headers", - "check:i18n": "ng xi18n --outFile ../i18n/messages.xlf && xliffmerge", + "check:i18n": "ng xi18n --outFile ../i18n/messages.xlf && aio/scripts/xliffmerge.sh", "fix": "concurrently \"npm run fix:backend\" \"npm run fix:frontend\" \"npm run fix:license\" \"npm run fix:i18n\"", "fix:backend": "golangci-lint run -c .golangci.yml --fix src/app/backend/...", "fix:frontend": "concurrently \"npm run fix:frontend:ts\" \"npm run fix:frontend:scss\" \"npm run fix:frontend:html\"", @@ -51,7 +51,7 @@ "fix:frontend:scss": "scssfmt -r 'src/**/*.scss'", "fix:frontend:html": "./aio/scripts/format.sh --html", "fix:license": "gulp update-license-headers", - "fix:i18n": "ng xi18n --outFile ../i18n/messages.xlf && xliffmerge", + "fix:i18n": "ng xi18n --outFile ../i18n/messages.xlf && aio/scripts/xliffmerge.sh", "clean": "rm -rf .go_workspace .tmp coverage dist npm-debug.log", "postversion": "node aio/scripts/version.js", "postinstall": "node aio/scripts/version.js && command -v golangci-lint >/dev/null 2>&1 || { curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.17.1; } && go mod download"