Compare commits
70 Commits
dev
...
screenshot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9588895282 | ||
|
|
6bc1ddbac6 | ||
|
|
4201c70874 | ||
|
|
6be95ea336 | ||
|
|
c6c22a176d | ||
|
|
c98e16d5df | ||
|
|
2638c437ba | ||
|
|
beb8981454 | ||
|
|
9f4605d876 | ||
|
|
5a076ae854 | ||
|
|
7362485714 | ||
|
|
b4e8074916 | ||
|
|
ec39d4cc6c | ||
|
|
9a6b1c1fdc | ||
|
|
8856345353 | ||
|
|
cc8cce41a4 | ||
|
|
84054bd54c | ||
|
|
95c08ee850 | ||
|
|
2532e2fe45 | ||
|
|
6eae46c6de | ||
|
|
5ea63c3403 | ||
|
|
1da10668b5 | ||
|
|
5b4e13637d | ||
|
|
f97bb3cb4f | ||
|
|
dfcc21a506 | ||
|
|
735d85c892 | ||
|
|
4d6ef64f8a | ||
|
|
e3c03974d5 | ||
|
|
7c11b5a47a | ||
|
|
f9238e1934 | ||
|
|
1298dc1ddd | ||
|
|
c3f876e8dd | ||
|
|
ee679a8019 | ||
|
|
e3a0215869 | ||
|
|
f913825ba6 | ||
|
|
34cd9c832a | ||
|
|
7af1edfd42 | ||
|
|
8c053cb76c | ||
|
|
2230aa4e75 | ||
|
|
1b1ff87dff | ||
|
|
4a9861f129 | ||
|
|
3a0603c154 | ||
|
|
7f3f649247 | ||
|
|
d2fb00d580 | ||
|
|
09482030da | ||
|
|
cf949d2af6 | ||
|
|
6adc17b962 | ||
|
|
febcb16b06 | ||
|
|
f4bcdbcfaf | ||
|
|
32e74d037c | ||
|
|
ffc5cca16e | ||
|
|
2e8bb1d00c | ||
|
|
d1546d0ee3 | ||
|
|
78e59f1ff4 | ||
|
|
990197dc87 | ||
|
|
0a1f06a587 | ||
|
|
d1dd257fd4 | ||
|
|
58304ea073 | ||
|
|
a762233a8c | ||
|
|
ef18dd8e01 | ||
|
|
48d070723d | ||
|
|
09a6d27107 | ||
|
|
6f74857578 | ||
|
|
d5035fe13e | ||
|
|
462bd34299 | ||
|
|
554278c8ec | ||
|
|
bf3611a937 | ||
|
|
0ec6f42d14 | ||
|
|
983f3fdde6 | ||
|
|
2e1f94e6ec |
19
.github/diff_report/diff_screenshots.py
vendored
19
.github/diff_report/diff_screenshots.py
vendored
@ -2,9 +2,9 @@
|
||||
Utility to compare screenshots before and after a change and generate a report of the
|
||||
differences.
|
||||
|
||||
Expected usage in a GitHub Actions workflow; compare `dev` with the `$INCOMING_CHANGES_REF` in the
|
||||
associated PR or merge that triggered the CI run:
|
||||
python src/seedsigner/resources/seedsigner-translations/.github/diff_report/diff_screenshots.py ./artifacts/dev ./artifacts/incoming ./artifacts/diff $INCOMING_CHANGES_REF
|
||||
Expected usage in a GitHub Actions workflow; compare `dev` with the `$BRANCH_NAME` in the
|
||||
associated PR that triggered the CI run:
|
||||
python src/seedsigner/resources/seedsigner-translations/.github/diff_report/diff_screenshots.py ./artifacts/dev ./artifacts/$BRANCH_NAME ./artifacts/diff
|
||||
"""
|
||||
import argparse
|
||||
import glob
|
||||
@ -16,16 +16,15 @@ import shutil
|
||||
|
||||
parser = argparse.ArgumentParser(prog=__name__)
|
||||
|
||||
parser.add_argument("before_dir", type=str, help="Directory containing screenshots before the incoming changes")
|
||||
parser.add_argument("after_dir", type=str, help="Directory containing screenshots after the incoming changes")
|
||||
parser.add_argument("before_dir", type=str, help="Directory containing screenshots before the proposed changes")
|
||||
parser.add_argument("after_dir", type=str, help="Directory containing screenshots after the proposed changes")
|
||||
parser.add_argument("output_dir", type=str, help="Directory to save the screenshots diff report")
|
||||
parser.add_argument("incoming_changes_ref", type=str, help="Branch name or commit hash that contains the incoming changes")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# `before_dir` includes the branch name we'll be merging into
|
||||
baseline_branch = args.before_dir.split(os.path.sep)[-1]
|
||||
incoming_changes_ref = args.incoming_changes_ref
|
||||
# "before" and "after" directories are named: artifacts/$TARGET_BRANCH and artifacts/$BRANCH_NAME
|
||||
before_branch_name = args.before_dir.split(os.path.sep)[-1]
|
||||
after_branch_name = args.after_dir.split(os.path.sep)[-1]
|
||||
|
||||
def list_files_recursively(path: str) -> list[str]:
|
||||
""" Return a list of paths to all png files in the directory tree """
|
||||
@ -92,7 +91,7 @@ for file in list_files_recursively(args.after_dir):
|
||||
only_in_before = set(paths_before) - set(paths_after)
|
||||
|
||||
html_content = "<h1>Screenshots diff report</h1>"
|
||||
html_content += f"""<p>Comparing {baseline_branch} to {incoming_changes_ref}</p>"""
|
||||
html_content += f"""<p>Comparing {before_branch_name} to {after_branch_name}</p>"""
|
||||
output_dir_before = os.path.join(args.output_dir, "before")
|
||||
output_dir_after = os.path.join(args.output_dir, "after")
|
||||
os.makedirs(output_dir_before, exist_ok=True)
|
||||
|
||||
12
.github/workflows/tests.yml
vendored
12
.github/workflows/tests.yml
vendored
@ -20,9 +20,7 @@ jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
# head_ref: source branch name of a PR; null when action isn't a PR.
|
||||
# sha: hash of a commit / merge.
|
||||
INCOMING_CHANGES_REF: ${{ github.head_ref || github.sha }}
|
||||
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
||||
steps:
|
||||
- name: Checkout main repo 'dev'
|
||||
uses: actions/checkout@v4
|
||||
@ -66,17 +64,17 @@ jobs:
|
||||
- name: Generate latest screenshots
|
||||
run: |
|
||||
rm -rf seedsigner-screenshots
|
||||
mkdir -p artifacts/incoming
|
||||
mkdir -p artifacts/$BRANCH_NAME
|
||||
python -m pytest tests/screenshot_generator/generator.py
|
||||
sleep 10
|
||||
mv ./seedsigner-screenshots/* ./artifacts/incoming/
|
||||
mv ./seedsigner-screenshots/* ./artifacts/$BRANCH_NAME/
|
||||
- name: Diff screenshots
|
||||
run: |
|
||||
mkdir -p artifacts/diff
|
||||
python src/seedsigner/resources/seedsigner-translations/.github/diff_report/diff_screenshots.py ./artifacts/dev ./artifacts/incoming ./artifacts/diff $INCOMING_CHANGES_REF
|
||||
python src/seedsigner/resources/seedsigner-translations/.github/diff_report/diff_screenshots.py ./artifacts/dev ./artifacts/$BRANCH_NAME ./artifacts/diff
|
||||
- name: Clean up artifacts
|
||||
run: |
|
||||
rm -rf ./artifacts/incoming
|
||||
rm -rf ./artifacts/$BRANCH_NAME
|
||||
rm -rf ./artifacts/dev
|
||||
mv ./artifacts/diff/* ./artifacts
|
||||
rmdir ./artifacts/diff
|
||||
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,5 +1 @@
|
||||
.DS_Store
|
||||
|
||||
# Only check in *.po files since *.mo
|
||||
# files can be generated from from them
|
||||
*.mo
|
||||
|
||||
12
.tx/config
12
.tx/config
@ -1,12 +0,0 @@
|
||||
[main]
|
||||
host = https://app.transifex.com
|
||||
|
||||
[o:seedsigner:p:seedsigner:r:messagespot]
|
||||
file_filter = l10n/<lang>/LC_MESSAGES/messages.po
|
||||
source_file = ../../../../l10n/messages.pot
|
||||
type = PO
|
||||
minimum_perc = 15
|
||||
resource_name = messages.pot
|
||||
replace_edited_strings = false
|
||||
keep_translations = false
|
||||
lang_map = zh-Hans: zh_Hans_CN
|
||||
48
README.md
48
README.md
@ -1,47 +1 @@
|
||||
# SeedSigner Translations
|
||||
|
||||
## Transifex CLI
|
||||
You can pull the latest translations directly from Transifex for all translated languages.
|
||||
|
||||
You'll need to create a Transifex user if you don't already have one. Your user will also
|
||||
need some minimal role permissions within the SeedSigner Transifex project in order for
|
||||
your user's API key to have access to the translations data.
|
||||
|
||||
* Install the [Transifex CLI](https://developers.transifex.com/docs/cli).
|
||||
* [Create an API key](https://help.transifex.com/en/articles/6248858-generating-an-api-token)
|
||||
for your Transifex user.
|
||||
* From the `seedsigner/src/seedsigner/resources/seedsigner-translations` dir run:
|
||||
|
||||
```bash
|
||||
# --force, -f Force the download of the translations files regardless of whether timestamps on the local computer are newer than those on the server (default: false)
|
||||
# --all, -a Whether to download all files (default: false)
|
||||
tx pull -f --all
|
||||
```
|
||||
* We use `-f` because as we manipulate the .po files through our PR process, they may
|
||||
end up with newer timestamps even though the translation content has not changed.
|
||||
That timestamp would then mislead the `tx pull` to disregard newer translations.
|
||||
|
||||
* Then from the SeedSigner project root, compile the catalogs to process the *.po files into
|
||||
*.mo:
|
||||
|
||||
```bash
|
||||
python setup.py compile_catalog
|
||||
```
|
||||
|
||||
### Pulling translations for a specific language
|
||||
Use the `--language, -l` flag with the `--force, -f` flag:
|
||||
```bash
|
||||
# Example: Spanish ("es")
|
||||
tx pull -f -l es
|
||||
|
||||
# Or comma-separated list
|
||||
tx pull -f -l pl,no
|
||||
```
|
||||
|
||||
|
||||
### Misc notes
|
||||
The `.tx/config` is set to `minimum-perc = 15` (this means that the CLI will skip any
|
||||
language whose translation completion falls below this minimum percentage).
|
||||
|
||||
You can manually override this by adding, for example, `--minimum-perc 25` to require at
|
||||
least 25% translation completion.
|
||||
# SeedSigner Translations
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
BIN
l10n/es/LC_MESSAGES/messages.mo
Normal file
BIN
l10n/es/LC_MESSAGES/messages.mo
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,74 +0,0 @@
|
||||
"""
|
||||
Extracts all unique characters that appear in the translated strings for the specified
|
||||
locale.
|
||||
|
||||
This is a utility for build / dev purposes only.
|
||||
"""
|
||||
|
||||
if __name__ == "__main__":
|
||||
import argparse
|
||||
import os
|
||||
from babel.messages import mofile
|
||||
|
||||
# Define required input args and help text
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Extracts all unique characters that appear in the translated strings for the specified locale."
|
||||
)
|
||||
parser.usage = "python3 extract_characters_from_babel_mo.py <locale>"
|
||||
parser.add_argument("locale", help="Target locale (e.g. es, pt_BR, zh_Hans_CN)")
|
||||
parser.add_argument("--debug", action="store_true", help="Enable debug output")
|
||||
args = parser.parse_args()
|
||||
debug = args.debug
|
||||
|
||||
basic_chars = set((chr(c) for c in range(0x20, 0x7E + 1))) # all basic ascii chars from SPACE to "~"
|
||||
|
||||
mo_fullfilename = os.path.join(os.pardir, "l10n", args.locale, "LC_MESSAGES", "messages.mo")
|
||||
try:
|
||||
with open(mo_fullfilename, "rb") as f:
|
||||
catalog = mofile.read_mo(f)
|
||||
except FileNotFoundError:
|
||||
print(f"Could not find translations for locale \"{args.locale}\" ({mo_fullfilename})")
|
||||
exit(1)
|
||||
|
||||
id_chars = set()
|
||||
translations_chars = set()
|
||||
for msg in catalog:
|
||||
if msg.id:
|
||||
if isinstance(msg.id, list):
|
||||
# plural message
|
||||
# get chars from all plural forms
|
||||
for msgid in msg.id:
|
||||
id_chars.update(msgid)
|
||||
else:
|
||||
# singular message
|
||||
id_chars.update(msg.id)
|
||||
if msg.string:
|
||||
if isinstance(msg.string, list):
|
||||
# plural message
|
||||
# get chars from all plural forms
|
||||
for msgstring in msg.string:
|
||||
translations_chars.update(msgstring)
|
||||
else:
|
||||
# singular message
|
||||
translations_chars.update(msg.string)
|
||||
|
||||
if debug:
|
||||
# Print the difference between the chars in the ids vs the basic_chars
|
||||
print("Chars in ids but not in basic_chars:", sorted(set("".join(id_chars)) - set(basic_chars)))
|
||||
|
||||
# And show the opposite
|
||||
print("Chars in basic_chars but not in ids:", sorted(basic_chars - set("".join(id_chars))))
|
||||
|
||||
print("Chars in translations:", "".join(sorted(translations_chars)))
|
||||
|
||||
# get a unique list of chars from all translation messages and included_chars string
|
||||
chars = sorted(translations_chars.union(basic_chars))
|
||||
|
||||
# convert set to string
|
||||
chars_string = "".join(chars)
|
||||
|
||||
# remove newlines
|
||||
chars_string = chars_string.replace("\n", "").replace("\r", "")
|
||||
|
||||
print(chars_string)
|
||||
@ -1 +0,0 @@
|
||||
Babel
|
||||
Loading…
Reference in New Issue
Block a user