* Update locales generation

* Update README

* Disable translation check

---------

Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
This commit is contained in:
Daniel Girtler 2023-09-28 08:44:18 +10:00 committed by GitHub
parent 72856ed5ec
commit 1e296b2637
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 81 additions and 36 deletions

View File

@ -1,28 +1,28 @@
on:
push:
paths:
- 'archinstall/locales/**'
pull_request:
paths:
- 'archinstall/locales/**'
name: Verify local_generate script was run on translation changes
jobs:
translation-check:
runs-on: ubuntu-latest
container:
image: archlinux:latest
steps:
- uses: actions/checkout@v4
- run: pacman --noconfirm -Syu python git diffutils
- name: Verify all translation scripts are up to date
run: |
cd ..
cp -r archinstall archinstall_orig
cd archinstall/archinstall/locales
bash locales_generator.sh 1> /dev/null
cd ../../..
git diff \
--quiet --no-index --name-only \
archinstall_orig/archinstall/locales \
archinstall/archinstall/locales \
|| (echo "Translation files have not been updated after translation, please run ./locales_generator.sh once more and commit" && exit 1)
#on:
# push:
# paths:
# - 'archinstall/locales/**'
# pull_request:
# paths:
# - 'archinstall/locales/**'
#name: Verify local_generate script was run on translation changes
#jobs:
# translation-check:
# runs-on: ubuntu-latest
# container:
# image: archlinux:latest
# steps:
# - uses: actions/checkout@v4
# - run: pacman --noconfirm -Syu python git diffutils
# - name: Verify all translation scripts are up to date
# run: |
# cd ..
# cp -r archinstall archinstall_orig
# cd archinstall/archinstall/locales
# bash locales_generator.sh 1> /dev/null
# cd ../../..
# git diff \
# --quiet --no-index --name-only \
# archinstall_orig/archinstall/locales \
# archinstall/archinstall/locales \
# || (echo "Translation files have not been updated after translation, please run ./locales_generator.sh once more and commit" && exit 1)

View File

@ -73,6 +73,14 @@ how much has been translated.
Any contributions to the translations are more than welcome,
to get started please follow [the guide](https://github.com/archlinux/archinstall/blob/master/archinstall/locales/README.md)
## Fonts
The ISO does not ship with ship with all fonts needed for different languages.
Fonts that are using a different character set than Latin will not be displayed correctly. If those languages
want to be selected than a proper font has to be set manually in the console.
All available console fonts can be found in `/usr/share/kbd/consolefonts` and can be set with `setfont LatGrkCyr-8x16`.
# Scripting your own installation
## Scripting interactive installation

View File

@ -14,15 +14,15 @@ can be set with `setfont LatGrkCyr-8x16`
## Adding new languages
New languages can be added simply by creating a new folder with the proper language abbreviation (see list `languages.json` if unsure).
New languages can be added simply by creating a new folder with the proper language abbreviation (see list `languages.json` if unsure).
Run the following command to create a new template for a language
```
mkdir -p <abbr>/LC_MESSAGES/ && touch <abbr>/LC_MESSAGES/base.po
```
After that run the script `./locales_generator.sh` it will automatically populate the new `base.po` file with the strings that
need to be translated into the new language.
For example the `base.po` might contain something like the following now
After that run the script `./locales_generator.sh <lang_abbr>` it will automatically populate the new `base.po` file with the strings that
need to be translated into the new language.
For example the `base.po` might contain something like the following now
```
#: lib/user_interaction.py:82
msgid "Do you really want to abort?"
@ -30,7 +30,7 @@ msgstr ""
```
The `msgid` is the identifier of the string in the code as well as the default text to be displayed, meaning that if no
translation is provided for a language then this is the text that is going to be shown.
translation is provided for a language then this is the text that is going to be shown.
To perform translations for a language this file can be edited manually or the neat `poedit` can be used (https://poedit.net/).
If editing the file manually, write the translation in the `msgstr` part

View File

@ -2,11 +2,48 @@
cd $(dirname "$0")/..
find . -type f -iname "*.py" | xargs xgettext --join-existing --no-location --omit-header -d base -o locales/base.pot
function update_lang() {
file=$1
for file in $(find locales/ -name "base.po"); do
echo "Updating: $file"
path=$(dirname $file)
msgmerge --quiet --no-location --width 512 --backup none --update $file locales/base.pot
msgfmt -o $path/base.mo $file
done
}
function generate_all() {
for file in $(find locales/ -name "base.po"); do
update_lang "$file"
done
}
function generate_single_lang() {
lang_file="locales/$1/LC_MESSAGES/base.po"
if [ ! -f "$lang_file" ]; then
echo "Language files not found: $lang_file"
exit 1
fi
update_lang "$lang_file"
}
if [ $# -eq 0 ]
then
echo "Usage: locales_generator.sh <language_abbr>"
exit 1
fi
lang=$1
# Update the base file containing all translatable string
find . -type f -iname "*.py" | xargs xgettext --join-existing --no-location --omit-header -d base -o locales/base.pot
case "$lang" in
"all") generate_all
;;
*) generate_single_lang "$lang"
esac