-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #301 from endlessm/automate-translation
Translation scripts
- Loading branch information
Showing
7 changed files
with
116 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
# Wrapper script to try to execute the Godot binary. | ||
set -e | ||
|
||
get_godot_bin() { | ||
# GODOT environment variable preferred. | ||
if [ -n "$GODOT" ]; then | ||
echo "$GODOT" | ||
return 0 | ||
fi | ||
|
||
# godot in PATH. | ||
if type -p godot >/dev/null; then | ||
echo godot | ||
return 0 | ||
fi | ||
|
||
# Flatpak Godot with <installation>/exports/bin in PATH. | ||
if type -p org.godotengine.Godot >/dev/null; then | ||
echo org.godotengine.Godot | ||
return 0 | ||
fi | ||
|
||
# Flatpak Godot without <installation>/exports/bin in PATH. | ||
if flatpak info org.godotengine.Godot &>/dev/null; then | ||
echo "flatpak run org.godotengine.Godot" | ||
return 0 | ||
fi | ||
|
||
echo "error: Could not find godot executable, set GODOT environment variable" >&2 | ||
return 1 | ||
} | ||
|
||
godot_bin=$(get_godot_bin) | ||
exec $godot_bin "$@" |
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,14 @@ | ||
#!/bin/sh | ||
|
||
# Merge new strings from POT file into message catalogs. | ||
set -e | ||
|
||
SCRIPTDIR=$(dirname "$0") | ||
PROJDIR=$(dirname "$SCRIPTDIR") | ||
LOCALEDIR="$PROJDIR/addons/block_code/locale" | ||
POT="$LOCALEDIR/godot_block_coding.pot" | ||
|
||
for po in "$LOCALEDIR"/*.po; do | ||
echo -n "$po" | ||
msgmerge --update --backup=none "$po" "$POT" | ||
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,25 @@ | ||
## BlockCode POT regeneration script | ||
## | ||
## Use this on the Godot command line with the --script option. This depends on | ||
## the Godot editor, so the --editor option is also required. | ||
extends SceneTree | ||
|
||
const TxUtils := preload("res://addons/block_code/translation/utils.gd") | ||
|
||
|
||
# Everything happens in _process to ensure the editor is fully initialized. | ||
func _process(_delta): | ||
if Engine.is_editor_hint(): | ||
TxUtils.regenerate_pot_file() | ||
else: | ||
push_error("%s can only be run with --editor" % get_script().resource_path) | ||
|
||
# Stop processing the main loop. | ||
return true | ||
|
||
|
||
# The editor won't be shut down in the normal way, which will cause a bunch of | ||
# leaks. There's nothing we can do about that and we don't care about them, | ||
# anyways. Let the user following along know this is OK. | ||
func _finalize(): | ||
print_rich("[b]%s causes Godot to leak resources. Ignore the warnings and errors![/b]" % get_script().resource_path.get_file()) |
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,11 @@ | ||
#!/bin/sh | ||
|
||
# Wrapper script to try to execute the regenerate-pot.gd main loop script. | ||
set -e | ||
|
||
SCRIPTDIR=$(dirname "$0") | ||
PROJDIR=$(dirname "$SCRIPTDIR") | ||
GODOT_SH="$SCRIPTDIR/godot.sh" | ||
SCRIPT="$SCRIPTDIR/regenerate-pot.gd" | ||
|
||
exec "$GODOT_SH" --path "$PROJDIR" --headless --editor --script "$SCRIPT" |
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,11 @@ | ||
## BlockCode update translated files script | ||
## | ||
## Use this on the Godot command line with the --script option. | ||
extends SceneTree | ||
|
||
const TxUtils := preload("res://addons/block_code/translation/utils.gd") | ||
|
||
|
||
func _init(): | ||
TxUtils.update_pot_files() | ||
quit() |
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,11 @@ | ||
#!/bin/sh | ||
|
||
# Wrapper script to try to execute the update-pot-files.gd main loop script. | ||
set -e | ||
|
||
SCRIPTDIR=$(dirname "$0") | ||
PROJDIR=$(dirname "$SCRIPTDIR") | ||
GODOT_SH="$SCRIPTDIR/godot.sh" | ||
SCRIPT="$SCRIPTDIR/update-pot-files.gd" | ||
|
||
exec "$GODOT_SH" --path "$PROJDIR" --headless --script "$SCRIPT" |