Skip to content

Commit 6a53099

Browse files
ivan-hczen0bitweb-flowfiftydinar
authored
"AM" 9.8 - add support to locale and languages (#1582)
* Localization (#1459) * translation script * allow translation * am.pot RAW still need cleanup * cs.po manually cleaned * Add empty it translation * am.pot * empty translation file * cs mo * it mo (empty) * translate module * localization * translation module * translation in help message * rm temp.po * gumG as green * Add colors * am.po am.pot * Reset colors in APP-MANAGER * cs.po cs.mo * cs.po~ (backup) * revert chages in installers git checkout dev -- INSTALL AM-INSTALLER * fix copying .mo * am.po am.pot * cs * it * translations in $HOME * move .po file * update * Show only date not more.. * Add translations action * Move .mo files under po/ * Delete not needed trans.sh * update * translation copy timeout (for CI) * no choosen branch to run on * CI: Clone translations repo * Add gettext dependency * Git add translation files * fix git add * Copy files from /opt/am/ * Rename po dir to translations * Remove usr dir * git status * Trigger if module or APP-MANAGER change * Upload mo files * ci * Release translations * fix release * Github-Release-Action * Update translations.yml * Use github.workflow for trigger * comment out * Update translations.yml * Update translations.yml * s * mention release * run-name * Update translations.yml * Update translations.yml * remarkablemark/gitploy-action * to translations branch * Update translations.yml * Include upstream changes * 🦉 translations * git rm * 🦉 translations * Update translations.yml * Delete translations * 🦉 translations * Remove *.po~ in module * 🦉 translations * 🦉 translations --------- Co-authored-by: web-flow <[email protected]> * 🦉 translations * Fix colors (#1580) * 🦉 translations * Fix colors --------- Co-authored-by: web-flow <[email protected]> * 🦉 translations * Update APP-MANAGER * Update APP-MANAGER * Temporarily disable translations function * Use dynamic "fit" if command "tput" is available * Move some messages to one line * Add help.am * Remove the help message, now moved into a dedicated module - sort options of modules - handle NO_COLOR in modules * Fix color / no-color switch in "-h" * Sort internal options by name * Allow no-colors in "-u" * Detect available locale files * Update APP-MANAGER * Add help module to export * Use owner repo * 🦉 translations * check * Add files via upload * 🦉 translations * Update translate.am - refactoring, improve readability * Put the help message back to APP-MANAGER (#1585) * Restore the help message to the main CLI * Delete modules/help.am * Update translate.am - remove modules/help.am reference * Need a $ * Check if LANG value is not "C" * Include "translate" related options in shell completion * Delete results directory * Set the language in a "locale" file (which I will work on in the future) * Set "en" if no locale is available for you * Use "monorepo" to fix wrong locale file download * Add function to sincronize locale file, if available * Add option "translate", can be used with or without arguments * Fix command "am translate en" * Update APP-MANAGER * Delete translations directory, moved to https://github.com/AM-community * Delete translations.yml, moved to https://github.com/AM-community * Update APP-MANAGER * Set and use alternative languages * Add option "--translate" or "translate" * Suggest using "am translate" to set alternative languages * Update README.md * Update README.md * Update APP-MANAGER - "AM" 9.8 * Check and set locale at first start * Suggest the valid locale codes (supports more than 2 letters) * Move _fit function before every function / improve "tput" output * Simplify the way to set locale * Delete modules/translate.am * Notify the user that the language has changed... ... and suggest how to switch back to English * Undo previous commit (issues in "-s") * Pertially undo 19c616d * Add strings-extractor.sh, update source.po and source.pot * Update strings-extractor.sh * Update translations/source* files * Add files via upload * Update strings-extractor.sh * Check and set developer mode at very start * Update source files * Update translations source * Update README.md * Update it.po * Update it.po * Update it.po * Update it.po * Update source files * Update strings-extractor.sh * Update it.po * Add files via upload * Update it.po * Add files via upload * Update README.md * Update README.md * Create README.md * Update Serbian translation (#1603) * Update Serbian translation * Update am.mo * Add files via upload * Add files via upload * Add files via upload * Add files via upload * Update README.md * Update Serbian translate, help message fully translated (#1604) * Update Italian language - fix help message * Fix typo * Delete translations/locale/it/LC_MESSAGES directory * Update italian * Delete translations/usr/locale/it/LC_MESSAGES directory * Update italian * Add files via upload * Add files via upload * Update source files * Update template.am * Update and rename strings-extractor.sh to LANGUAGE-MANAGER * Create language-updater.yml * Update language-updater.yml * Update language-updater.yml * Update language-updater.yml * Update language-updater.yml * Update language-updater.yml * Update language-updater.yml * Sync locale files * Update language-updater.yml * Update language-updater.yml * Sync locale files * Fix wrong URLs and English "help" message in 5 locales * Sync locale files * Update README.md * Update README.md * Serbian translation, update typo in help (#1605) * Sync locale files * Move .po files to a dedicated directory (#1607) * Rename translations/cs.po to translations/po-files/cs.po * Rename translations/de.po to translations/po-files/de.po * Rename translations/es.po to translations/po-files/es.po * Rename translations/it.po to translations/po-files/it.po * Rename translations/ru.po to translations/po-files/ru.po * Rename translations/sr.po to translations/po-files/sr.po * Update README.md * Update LANGUAGE-MANAGER * Update language-updater.yml * Fix missing "\n" in de, es and ru * Sync locale files * Remove AI generated translations (#1608) * Delete translations/po-files/de.po * Delete translations/po-files/es.po * Delete translations/po-files/ru.po * Delete translations/usr/share/locale/de/LC_MESSAGES directory * Delete translations/usr/share/locale/es/LC_MESSAGES directory * Delete translations/usr/share/locale/ru/LC_MESSAGES directory * Fix Serbian language typo & update language description (#1609) * Sync locale files * Remove wrong translated "help" message from 4 translations * Sync locale files * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Improve language detection logic (#1610) * Improve language detection logic All symbols after `_` are variants of one language, so I just remove all those symbols. As a result, detection is `sr` instead of `sr_RS` * Also remove strings after @ symbol * Remove `cut -c -2` when getting `iso_code` from `locale` file * Notify about the availability of a translation package in "-s" an "-u" * Sync locale files * Update LANGUAGE-MANAGER * Update language-updater.yml * Update LANGUAGE-MANAGER * Update language-updater.yml * Sync locale files * Update LANGUAGE-MANAGER * Update LANGUAGE-MANAGER * Update language-updater.yml * Update language-updater.yml * Remove only am.mo and appman.mo, not all .mo files * Sync locale files * Update README.md --------- Co-authored-by: zenobit <[email protected]> Co-authored-by: web-flow <[email protected]> Co-authored-by: fiftydinar <[email protected]>
1 parent 070deba commit 6a53099

File tree

24 files changed

+18456
-414
lines changed

24 files changed

+18456
-414
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: "Language Manager"
2+
3+
on:
4+
push:
5+
branches: dev
6+
paths:
7+
- APP-MANAGER
8+
- modules/*.am
9+
- translations/po-files/*.po
10+
- .github/workflows/language-updater.yml
11+
12+
workflow_dispatch:
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
permissions:
19+
contents: write
20+
21+
jobs:
22+
sync-files:
23+
name: "Sync locale files"
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: "Checkout source repository"
27+
uses: actions/checkout@v4
28+
29+
- name: "Cache dependencies"
30+
uses: awalsh128/cache-apt-pkgs-action@latest
31+
with:
32+
packages: gettext
33+
version: 1.0
34+
35+
- name: "Run Language Manager"
36+
run: |
37+
./LANGUAGE-MANAGER
38+
39+
- name: "Push to Source"
40+
run: |
41+
git config --global user.name "ivan-hc"
42+
git config --global user.email "[email protected]"
43+
git add translations
44+
if git diff-index --quiet HEAD; then
45+
echo "No changes to commit." >> $GITHUB_STEP_SUMMARY
46+
else
47+
git commit -m "Sync locale files"
48+
git push && echo "Sync locale files" >> $GITHUB_STEP_SUMMARY
49+
fi

APP-MANAGER

Lines changed: 282 additions & 166 deletions
Large diffs are not rendered by default.

LANGUAGE-MANAGER

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env bash
2+
3+
DIVIDING_LINE="-----------------------------------------------------------------------------"
4+
5+
################################################################################################################################################################
6+
# Extract strings from APP-MANAGER and modules
7+
################################################################################################################################################################
8+
9+
[ -f ./APP-MANAGER ] && AMVERSION=$(grep "^AMVERSION=" APP-MANAGER | tr '"' '\n' | grep "^[0-9]") || AMVERSION=$(am -v)
10+
11+
mkdir -p translations && rm -f translations/source.*
12+
13+
cat <<-HEREDOC >> translations/source.pot
14+
# File with translation for AM
15+
# FIRST AUTHOR <EMAIL@ADDRESS>, $(date +"%Y")
16+
msgid ""
17+
msgstr ""
18+
"Project-Id-Version: AM ${AMVERSION}\n"
19+
"Report-Msgid-Bugs-To: https://github.com/ivan-hc/AM\n"
20+
"POT-Creation-Date: $(date +"%Y-%m-%d")\n"
21+
"PO-Revision-Date: $(date +"%Y-%m-%d")\n"
22+
"Last-Translator: John Doe <[email protected]>\n"
23+
"Language-Team: English <[email protected]>\n"
24+
"MIME-Version: 1.0\n"
25+
"Content-Type: text/plain; charset=UTF-8\n"
26+
"Content-Transfer-Encoding: 8bit\n"
27+
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
28+
HEREDOC
29+
30+
items="APP-MANAGER modules/database.am modules/install.am modules/management.am modules/sandboxes.am modules/template.am"
31+
if [ ! -f ./APP-MANAGER ]; then
32+
for item in $items; do
33+
bash --dump-po-strings "/opt/am/$item" >> translations/source.pot
34+
done
35+
else
36+
for item in $items; do
37+
bash --dump-po-strings "$item" >> translations/source.pot
38+
done
39+
fi
40+
41+
msguniq translations/source.pot -o translations/source.po
42+
43+
msgcat --output-file=translations/source.pot --unique --indent --no-wrap translations/source.po
44+
45+
sed -i 's# /opt/am/# am/#g' translations/source*
46+
47+
if [ -s translations/source.po ] && [ -s translations/source.pot ]; then
48+
printf "%b\nSources are updated! \n%b\n" "$DIVIDING_LINE" "$DIVIDING_LINE"
49+
else
50+
printf "%b\nSomething went wrong, a source file is empty, exiting... \n%b\n" "$DIVIDING_LINE" "$DIVIDING_LINE" && exit 1
51+
fi
52+
53+
54+
################################################################################################################################################################
55+
# Update translations and locale files
56+
################################################################################################################################################################
57+
58+
[ -d ./translations ] && po_files=$(find translations/po-files/* -name "*.po" | tr ' ' '\n' | grep ".po$" | grep -v "source" | xargs)
59+
60+
[ -z "$po_files" ] && echo "Something went wrong, exiting..." && exit 1
61+
62+
for l in $po_files; do
63+
locale=""
64+
locale=$(echo "$l" | sed 's:.*/::; s/.po$//g')
65+
printf "%b\n%b\n%b\n" "$DIVIDING_LINE" "$locale" "$DIVIDING_LINE"
66+
[ -z "$locale" ] && echo "Something went wrong, exiting..." && exit 1
67+
mkdir -p translations/usr/share/locale/"$locale"/LC_MESSAGES
68+
msgmerge -U "$l" translations/source.pot
69+
if [ ! -s "$l" ]; then
70+
echo "WARNING, $l is empty, exiting..." && exit 1
71+
else
72+
msgfmt -o translations/usr/share/locale/"$locale"/LC_MESSAGES/am.mo "$l"
73+
fi
74+
done
75+
76+
rm -f translations/po-files/*~
77+
78+
printf "%b\nAll localizationfiles are updated\n%b\n" "$DIVIDING_LINE" "$DIVIDING_LINE"

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ You can use the command `am -a {PROGRAM}` to view the description and get the so
5858

5959
- [Do you own a repository for AppImages external to this database? Follow these instructions!](#do-you-own-a-repository-for-appimages-external-to-this-database-follow-these-instructions)
6060

61+
[Translate "AM" in your local language](#translate-am-in-your-local-language)
62+
6163
[How to update all programs, for real!](#how-to-update-all-programs-for-real)
6264
- [How to update all installed apps](#how-to-update-all-installed-apps)
6365
- [How to update everything using Topgrade](#how-to-update-everything-using-topgrade)
@@ -307,6 +309,29 @@ For more details on how the `-e` or `extra` option works, see [here](https://git
307309
| [Back to "Main Index"](#main-index) |
308310
| - |
309311
312+
------------------------------------------------------------------------
313+
# Translate "AM" in your local language
314+
Since version 9.8 it is possible to add and use alternative languages ​​via the `translate` option, use:
315+
```
316+
am translate
317+
```
318+
or if using AppMan
319+
```
320+
appman translate
321+
```
322+
The command accepts reliable language codes (for example "it" for Italian, or "sr" for Serbian). In case the desired language is not in the database, it will default to English (code "en").
323+
324+
In the example, "AM" in Italian, Czech and Serbian
325+
326+
https://github.com/user-attachments/assets/a18f48b0-f389-4e94-a576-0031354d3cd5
327+
328+
### See "[translations/README.md](translations/README.md)" for more information!
329+
330+
------------------------------------------------------------------------
331+
332+
| [How to translate "AM"](translations/README.md) | [Back to "Main Index"](#main-index) |
333+
| - | - |
334+
310335
------------------------------------------------------------------------
311336
## How to update all programs, for real!
312337
Most of the apps managed by "AM" have a script called `AM-updater`. It tells how updates are checked when running the `am -u` command.
@@ -640,6 +665,18 @@ Updates this script to the latest version hosted.
640665
641666
Generate a custom installation script. To test the scripts, use the "`am -i '/path/to/script'`" command or enter the directory of the script and run the "`am -i ./script`" command, even using dedicated flags, if necessary (see "`-i`").
642667
668+
------------------------------------------------------------------------
669+
### `translate`, `--translate`
670+
671+
am --translate
672+
am --translate {CODE}
673+
674+
**Description**:
675+
676+
Download and set one or more language packs (if available), set "am" to English (default), your language or other languages.
677+
678+
See **[translations/README.md](translations/README.md)** for more information.
679+
643680
------------------------------------------------------------------------
644681
### `unhide`
645682
@@ -952,7 +989,7 @@ Below you can access documentation pages for common issues and frequently asked
952989
- *[repology](https://github.com/repology), the encyclopedia of all software versions*
953990

954991
#### Partner projects, i.e. those that actively contribute to this project
955-
- *[Toolpacks](https://github.com/pkgforge/soarpkgs), Largest Collection of Multi-Platform Pre-Compiled Static Binaries*
992+
- *[Soarpkgs](https://github.com/pkgforge/soarpkgs), Largest Collection of Multi-Platform Pre-Compiled Static Binaries*
956993

957994
#### My other projects
958995
- *[AppImaGen](https://github.com/ivan-hc/AppImaGen), easily create AppImages from Ubuntu PPAs or Debian using pkg2appimage and appimagetool*

0 commit comments

Comments
 (0)