Skip to content

Commit 838ef1c

Browse files
committed
scripts: Add update POT files CLI script and wrapper
This can be used to execute TxUtils.update_pot_files() from the CLI. The GDScript is a SceneTree script passed via Godot's --script CLI option. The shell script is a wrapper to execute Godot with all the necessary options. Unlike TxUtils.regenerate_pot(), the editor isn't required, so everything can happen from _init().
1 parent 4485a46 commit 838ef1c

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

addons/block_code/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ up to date.
8585
* If files are added or removed, the list of translatable files needs to be
8686
updated. This can be done by using the **Add** dialog in the [POT
8787
Generation][pot-generation] tab. Or you can use the **Project → Tools →
88-
Update BlockCode translated files** menu item in the editor.
88+
Update BlockCode translated files** menu item in the editor. From the command
89+
line, the POT file can be regenerated with the `scripts/update-pot-files.sh`
90+
shell script.
8991

9092
* If translatable strings have changed, the POT file needs to be updated. This
9193
can be done by using the **Generate POT** dialog in the [POT

scripts/update-pot-files.gd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## BlockCode update translated files script
2+
##
3+
## Use this on the Godot command line with the --script option.
4+
extends SceneTree
5+
6+
const TxUtils := preload("res://addons/block_code/translation/utils.gd")
7+
8+
9+
func _init():
10+
TxUtils.update_pot_files()
11+
quit()

scripts/update-pot-files.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
3+
# Wrapper script to try to execute the update-pot-files.gd main loop script.
4+
set -e
5+
6+
SCRIPTDIR=$(dirname "$0")
7+
PROJDIR=$(dirname "$SCRIPTDIR")
8+
GODOT_SH="$SCRIPTDIR/godot.sh"
9+
SCRIPT="$SCRIPTDIR/update-pot-files.gd"
10+
11+
exec "$GODOT_SH" --path "$PROJDIR" --headless --script "$SCRIPT"

0 commit comments

Comments
 (0)