Repository navigation
Expand file tree
/
Copy pathJustfile
More file actions
60 lines (51 loc) · 2.6 KB
/
Copy pathJustfile
File metadata and controls
60 lines (51 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package := "uwelcome"
version := "0.5.1"
# This returns the current version of uwelcome. It is used in the build command to set the version of the binary.
version:
@echo "Current version: {{version}}"
# This checks if the dependencies are on the user's system
check-deps: check-deps-go check-deps-gettext
@echo "All dependencies are installed ✅️"
check-deps-go:
@which go >/dev/null 2>&1 || (echo "You don't have \`go\` installed :(" && exit 1)
check-deps-gettext:
@which gettext >/dev/null 2>&1 || (echo "You don't have \`gettext\` installed :(" && exit 1)
# This builds the uwelcome binary for Linux on x86_64 and arm64 architectures.
build: check-deps-go
@echo "Building {{package}}..."
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o {{package}}_{{version}}_linux_amd64
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o {{package}}_{{version}}_linux_arm64
@echo "Built {{package}} v{{version}} for Linux on x86_64 and arm64"
# This extracts the strings from uwelcome and makes a potfile with them
extract-translations: check-deps-gettext
#!/bin/bash
echo "Extracting translations..."
find . -type f -name '*.go' -not -path './vendor/*' -print0 |
xargs -0 xgettext \
--language=Go \
--from-code=UTF-8 \
--keyword=Get \
--msgid-bugs-address=themimolet@proton.me \
--copyright-holder="The Project Bluefin Contributors" \
--package-version="{{version}}" \
--package-name="{{package}}" \
--output=locales/default.pot \
|| (echo "An error occurred while extracting translations :(" \
&& exit 1);
echo "Translations extracted ✅️"
# This generates the translation files for the specified language.
translate lang: extract-translations
#!/bin/bash
# If the language already exists, update it
if [ -f "locales/{{lang}}/default.po" ]; then \
echo "Translation file for \"{{lang}}\" already exists. Updating..." ;\
msgmerge -U locales/"{{lang}}"/default.po locales/default.pot || (echo "An error occurred while running \`msgmerge\` :(" && exit 1);\
rm -f locales/"{{lang}}"/default.po~;\
echo "File updated! You can edit it in locales/{{lang}}/default.po";\
exit 0;\
fi
# If the language does not exist, create it
echo "Translation file for \"{{lang}}\" do not exist. Creating new file..."
mkdir -p locales/"{{lang}}"/
msginit -i locales/default.pot -l "{{lang}}" -o locales/"{{lang}}"/default.po --no-translator
echo "Translation file generated. You can edit them in locales/{{lang}}/default.po"