forked from metabase/metabase
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:metabase/metabase into xray-async
- Loading branch information
Showing
113 changed files
with
2,542 additions
and
1,241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,5 @@ bin/release/aws-eb/metabase-aws-eb.zip | |
/build.xml | ||
/test-report-* | ||
/crate-* | ||
*.po~ | ||
/locales/metabase-*.pot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env node | ||
|
||
// This program compiles a ".po" translations file to a JSON version suitable for use on the frontend | ||
// It removes strings that aren't used on the frontend, and other extraneous information like comments | ||
|
||
const fs = require("fs"); | ||
const _ = require("underscore"); | ||
const gParser = require("gettext-parser"); | ||
|
||
if (process.argv.length !== 4) { | ||
console.log("USAGE: build-translation-frontend-resource input.po output.json"); | ||
process.exit(1); | ||
} | ||
|
||
const inputFile = process.argv[2]; | ||
const outputFile = process.argv[3]; | ||
|
||
const translationObject = gParser.po.parse(fs.readFileSync(inputFile, "utf-8")); | ||
|
||
// NOTE: unsure why the headers are duplicated in a translation for "", but we don't need it | ||
delete translationObject.translations[""][""] | ||
|
||
for (const id in translationObject.translations[""]) { | ||
const translation = translationObject.translations[""][id]; | ||
if (!translation.comments.reference || _.any(translation.comments.reference.split("\n"), reference => reference.startsWith("frontend/"))) { | ||
// remove comments: | ||
delete translation.comments; | ||
// NOTE: would be nice if we could remove the message id since it's redundant: | ||
// delete translation.msgid; | ||
} else { | ||
// remove strings that aren't in the frontend | ||
delete translationObject.translations[""][id]; | ||
} | ||
} | ||
|
||
fs.writeFileSync(outputFile, JSON.stringify(translationObject, null, 2), "utf-8"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
# gettext installed via homebrew is "keg-only", add it to the PATH | ||
if [ -d "/usr/local/opt/gettext/bin" ]; then | ||
export PATH="/usr/local/opt/gettext/bin:$PATH" | ||
fi | ||
|
||
POT_NAME="locales/metabase.pot" | ||
LOCALES=$(find locales -type f -name "*.po" -exec basename {} .po \;) | ||
LOCALES_QUOTED=$(echo "$LOCALES" | awk '{ printf "\"%s\" ", $0 }') | ||
|
||
FRONTEND_LANG_DIR="resources/frontend_client/app/locales" | ||
|
||
# backend | ||
# NOTE: include "en" even though we don't have a .po file for it because it's the default? | ||
cat << EOF > "resources/locales.clj" | ||
{ | ||
:locales #{"en" $LOCALES_QUOTED} | ||
:packages ["metabase"] | ||
:bundle "metabase.Messages" | ||
} | ||
EOF | ||
|
||
mkdir -p "$FRONTEND_LANG_DIR" | ||
|
||
for LOCALE in $LOCALES; do | ||
LOCALE_FILE="locales/$LOCALE.po" | ||
# frontend | ||
# NOTE: just copy these for now, but eventially precompile from .po to .json | ||
./bin/i18n/build-translation-frontend-resource \ | ||
"$LOCALE_FILE" \ | ||
"$FRONTEND_LANG_DIR/$LOCALE.json" | ||
|
||
# backend | ||
msgfmt \ | ||
--java2 \ | ||
-d "resources" \ | ||
-r "metabase.Messages" \ | ||
-l "$LOCALE" \ | ||
"$LOCALE_FILE" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
# gettext installed via homebrew is "keg-only", add it to the PATH | ||
if [ -d "/usr/local/opt/gettext/bin" ]; then | ||
export PATH="/usr/local/opt/gettext/bin:$PATH" | ||
fi | ||
|
||
POT_NAME="locales/metabase.pot" | ||
PO_NAME="locales/$1.po" | ||
|
||
if [ $# -lt 1 ]; then | ||
echo "USAGE: update-translation en_US" | ||
exit 1 | ||
fi | ||
|
||
if [ -f "$PO_NAME" ]; then | ||
exec msgmerge -U "$PO_NAME" "$POT_NAME" | ||
else | ||
exec msginit -i "$POT_NAME" -o "$PO_NAME" -l "$1" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
# gettext installed via homebrew is "keg-only", add it to the PATH | ||
if [ -d "/usr/local/opt/gettext/bin" ]; then | ||
export PATH="/usr/local/opt/gettext/bin:$PATH" | ||
fi | ||
|
||
# check xgettext is installed | ||
if ! command -v xgettext > /dev/null; then | ||
echo 'Please install the "xgettext" command (e.x. `brew install gettext`)' | ||
exit 1 | ||
fi | ||
|
||
POT_NAME="locales/metabase.pot" | ||
POT_BACKEND_NAME="locales/metabase-backend.pot" | ||
POT_FRONTEND_NAME="locales/metabase-frontend.pot" | ||
|
||
mkdir -p "locales" | ||
|
||
# update frontend pot | ||
|
||
# NOTE: about twice as fast to call babel directly rather than a full webpack build | ||
BABEL_ENV=extract ./node_modules/.bin/babel -q -x .js,.jsx -o /dev/null frontend/src | ||
# BABEL_ENV=extract BABEL_DISABLE_CACHE=1 yarn run build | ||
|
||
# update backend pot | ||
|
||
# xgettext before 0.19 does not understand --add-location=file. Even CentOS | ||
# 7 ships with an older gettext. We will therefore generate full location | ||
# info on those systems, and only file names where xgettext supports it | ||
LOC_OPT=$(xgettext --add-location=file -f - </dev/null >/dev/null 2>&1 && echo --add-location=file || echo --add-location) | ||
|
||
find src -name "*.clj" | xgettext \ | ||
--from-code=UTF-8 \ | ||
--language=lisp \ | ||
--copyright-holder='Metabase <[email protected]>' \ | ||
--package-name="metabase" \ | ||
--msgid-bugs-address="[email protected]" \ | ||
-k \ | ||
-kmark:1 -ki18n/mark:1 \ | ||
-ktrs:1 -ki18n/trs:1 \ | ||
-ktru:1 -ki18n/tru:1 \ | ||
-ktrun:1,2 -ki18n/trun:1,2 \ | ||
-ktrsn:1,2 -ki18n/trsn:1,2 \ | ||
$LOC_OPT \ | ||
--add-comments --sort-by-file \ | ||
-o $POT_BACKEND_NAME -f - | ||
|
||
sed -i "" -e 's/charset=CHARSET/charset=UTF-8/' "$POT_BACKEND_NAME" | ||
|
||
# merge frontend and backend pots | ||
msgcat "$POT_FRONTEND_NAME" "$POT_BACKEND_NAME" > "$POT_NAME" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
./bin/i18n/update-translation-template | ||
|
||
find locales -name "*.po" -exec sh -c './bin/i18n/update-translation $(basename {} .po)' \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
frontend/src/metabase/admin/settings/components/widgets/SettingSelect.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.