Skip to content

Conversation

@jasonqsong
Copy link
Contributor

@jasonqsong jasonqsong commented Nov 16, 2025

Transcode from zh_Hant translations

It looks like there isn't an active maintainer for Simplified Chinese on
Weblate, so I followed the translation guidelines and created this PR to update
the zh-Hans translation.

I'm aware that the Traditional Chinese translation is well-maintained by the
community. With that in mind, instead of translating with native Simplified
Chinese vocabulary, my strategy is to transcode the existing Traditional Chinese
resources. This strategy is similar to Wikipedia's. If the project maintainers
prefer a tone that is more native to Simplified Chinese speakers, I am more than
happy to rework this PR using that approach instead.

Thanks for taking the time to review this PR. I hope the community finds this work helpful.

FYI, Here's the helper script for transcoding the Traditional Chinese resources.

import re
import subprocess
import sys

app = sys.argv[1]

en_file = f"themes/src/main/resources/theme/base/{app}/messages/messages_en.properties"
hans_file = f"themes/src/main/resources-community/theme/base/{app}/messages/messages_zh_Hans.properties"
hant_file = f"themes/src/main/resources-community/theme/base/{app}/messages/messages_zh_Hant.properties"
if app == "account-ui":
    en_file = "js/apps/account-ui/maven-resources/theme/keycloak.v3/account/messages/messages_en.properties"
    hans_file = "js/apps/account-ui/maven-resources-community/theme/keycloak.v3/account/messages/messages_zh_Hans.properties"
    hant_file = "js/apps/account-ui/maven-resources-community/theme/keycloak.v3/account/messages/messages_zh_Hant.properties"
if app == "admin-ui":
    en_file = "js/apps/admin-ui/maven-resources/theme/keycloak.v2/admin/messages/messages_en.properties"
    hans_file = "js/apps/admin-ui/maven-resources-community/theme/keycloak.v2/admin/messages/messages_zh_Hans.properties"
    hant_file = "js/apps/admin-ui/maven-resources-community/theme/keycloak.v2/admin/messages/messages_zh_Hant.properties"


def parse_properties(content):
    content = re.sub(r"\s*\\\n\s*", " ", content)
    properties = {}
    for line in content.splitlines():
        if not line.startswith("#") and "=" in line:
            key, value = line.split("=", 1)
            key = key.replace("密码策略", "passwordPoliciesHelp")
            properties[key] = value
    return content, properties


en_properties = subprocess.run(
    f"cat {en_file}",
    shell=True,
    capture_output=True,
    text=True,
).stdout
hans_properties = subprocess.run(
    f"git show HEAD:{hans_file}",
    shell=True,
    capture_output=True,
    text=True,
    check=True,
).stdout
hant_properties = subprocess.run(
    f"opencc -c t2s -i {hant_file}",
    shell=True,
    capture_output=True,
    text=True,
    check=True,
).stdout

template, en_map = parse_properties(en_properties)
_, hans_map = parse_properties(hans_properties)
_, hant_map = parse_properties(hant_properties)

for key in hans_map:
    if key not in en_map:
        print(f"Missing: {key}", file=sys.stderr)

for line in template.splitlines():
    if not line.startswith("#") and "=" in line:
        key, en = line.split("=", 1)
        if key in hans_map:
            print(f"{key}={hans_map[key]}")
        elif key in hant_map:
            print(f"{key}={hant_map[key]}")
        else:
            print(f"{key}=[translate]{en}", file=sys.stderr)
    else:
        print(line)

Transcode from zh_Hant translations

Signed-off-by: Nagi <[email protected]>
@ahus1
Copy link
Contributor

ahus1 commented Nov 17, 2025

Thank you for this PR. Let's discuss in #9270 (comment) on how to proceed.

If you want this PR to be merged, please create a GitHub issue of type "enhancement" and update this PR so this change is then added to the next release notes.

@jasonqsong
Copy link
Contributor Author

Thank you for this PR. Let's discuss in #9270 (comment) on how to proceed.

If you want this PR to be merged, please create a GitHub issue of type "enhancement" and update this PR so this change is then added to the next release notes.

Thank you for looking into this. We can abandon this PR and switch to weblate

@jasonqsong jasonqsong closed this Nov 17, 2025
@jasonqsong jasonqsong deleted the zh-hans branch November 24, 2025 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants