mirror of
https://github.com/Oth3r/Sit.git
synced 2025-09-19 07:53:22 +02:00
lowercase locale
This commit is contained in:
parent
6c02b090ac
commit
e6eb46d7fa
5 changed files with 113 additions and 16 deletions
114
.github/workflows/crowdin-download-workflow.yml
vendored
114
.github/workflows/crowdin-download-workflow.yml
vendored
|
@ -3,31 +3,123 @@ name: Crowdin Download Action
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
actions: read
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
localization_branch_name:
|
||||||
|
description: 'The branch to create for the translations PR.'
|
||||||
|
required: true
|
||||||
|
default: 'crowdin/translations'
|
||||||
|
pull_request_base_branch:
|
||||||
|
description: 'The base branch for the pull request.'
|
||||||
|
required: true
|
||||||
|
default: 'dev'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
crowdin:
|
download-translations:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
# Checkout the BASE branch first. The PR branch will be created later.
|
||||||
|
- name: Checkout Base Branch
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.inputs.pull_request_base_branch }}
|
||||||
|
|
||||||
- name: Synchronize with Crowdin
|
- name: Configure Git User
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
|
- name: Synchronize with Crowdin (Download Only)
|
||||||
uses: crowdin/github-action@v2
|
uses: crowdin/github-action@v2
|
||||||
with:
|
with:
|
||||||
upload_sources: false
|
upload_sources: false
|
||||||
upload_translations: false
|
upload_translations: false
|
||||||
download_translations: true
|
download_translations: true
|
||||||
localization_branch_name: crowdin_translations
|
create_pull_request: false
|
||||||
|
localization_branch_name: ${{ github.event.inputs.localization_branch_name }}
|
||||||
create_pull_request: true
|
|
||||||
pull_request_title: 'Updated Crowdin translations'
|
|
||||||
pull_request_body: 'New Crowdin pull request with translations'
|
|
||||||
pull_request_base_branch_name: 'dev'
|
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
|
||||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
||||||
|
|
||||||
|
rename-files:
|
||||||
|
needs: download-translations
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout Localization Branch
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.inputs.localization_branch_name }}
|
||||||
|
|
||||||
|
- name: Configure Git User
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
|
- name: Rename JSON Files to Lowercase
|
||||||
|
env:
|
||||||
|
TARGET_DIR: "common/src/main/resources/assets/directionhud/lang/"
|
||||||
|
run: |
|
||||||
|
echo "Starting renaming process for JSON files within $TARGET_DIR..."
|
||||||
|
if [ ! -d "$TARGET_DIR" ]; then
|
||||||
|
echo "Warning: Target directory '$TARGET_DIR' does not exist. Skipping rename."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
find "$TARGET_DIR" -type f -name '*[A-Z]*.json' | while IFS= read -r file; do
|
||||||
|
original_path="$file"
|
||||||
|
dir_name=$(dirname "$original_path")
|
||||||
|
base_name=$(basename "$original_path")
|
||||||
|
new_base_name=$(echo "$base_name" | tr '[:upper:]' '[:lower:]')
|
||||||
|
new_path="$dir_name/$new_base_name"
|
||||||
|
if [ "$original_path" != "$new_path" ]; then
|
||||||
|
if [ -e "$new_path" ] && [ ! "$(readlink -f "$original_path")" = "$(readlink -f "$new_path")" ]; then
|
||||||
|
echo "::warning file=$original_path::Cannot rename '$original_path' to '$new_path' because it already exists. Skipping."
|
||||||
|
else
|
||||||
|
git mv "$original_path" "$new_path"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "JSON file renaming complete."
|
||||||
|
|
||||||
|
- name: Commit Renamed Files
|
||||||
|
run: |
|
||||||
|
echo "Committing renamed files..."
|
||||||
|
git add -A
|
||||||
|
git commit -m "Rename JSON translation files to lowercase for consistency"
|
||||||
|
echo "Renames committed."
|
||||||
|
|
||||||
|
- name: Push Changes to Localization Branch
|
||||||
|
run: |
|
||||||
|
echo "Pushing combined changes to ${{ github.event.inputs.localization_branch_name }}..."
|
||||||
|
git push origin ${{ github.event.inputs.localization_branch_name }}
|
||||||
|
|
||||||
|
create-pr:
|
||||||
|
needs: [ download-translations, rename-files ]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout branch
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.inputs.localization_branch_name }}
|
||||||
|
|
||||||
|
- name: Set up Git config
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions"
|
||||||
|
git config user.email "github-actions@github.com"
|
||||||
|
|
||||||
|
- name: Install GitHub CLI
|
||||||
|
run: sudo apt-get install gh -y
|
||||||
|
|
||||||
|
- name: Authenticate GitHub CLI
|
||||||
|
run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
|
||||||
|
|
||||||
|
- name: Create Pull Request
|
||||||
|
run: |
|
||||||
|
gh pr create \
|
||||||
|
--title "Update translations from Crowdin" \
|
||||||
|
--body "This PR includes:\n- New translations from Crowdin\n- Renamed translation files to lowercase" \
|
||||||
|
--head ${{ github.event.inputs.localization_branch_name }} \
|
||||||
|
--base ${{ github.event.inputs.pull_request_base_branch }} \
|
||||||
|
--label "localization"
|
|
@ -2,7 +2,7 @@ name: Crowdin Upload Action
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths: [ "src/main/resources/assets/sit-oth3r/lang/en_US.json"]
|
paths: [ "src/main/resources/assets/sit-oth3r/lang/en_us.json"]
|
||||||
branches: [ dev ]
|
branches: [ dev ]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
files: [
|
files: [
|
||||||
{
|
{
|
||||||
"source": "src/main/resources/assets/sit-oth3r/lang/en_US.json",
|
"source": "src/main/resources/assets/sit-oth3r/lang/en_us.json",
|
||||||
"translation": "src/main/resources/assets/sit-oth3r/lang/%locale_with_underscore%.json",
|
"translation": "src/main/resources/assets/sit-oth3r/lang/%locale_with_underscore%.json",
|
||||||
}
|
}
|
||||||
]
|
]
|
|
@ -27,12 +27,12 @@ import java.util.stream.Collectors;
|
||||||
public class ServerConfig implements CustomFile<ServerConfig> {
|
public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
|
|
||||||
@SerializedName("version")
|
@SerializedName("version")
|
||||||
private Double version = 2.2;
|
private Double version = 2.3;
|
||||||
|
|
||||||
@SerializedName("lang")
|
@SerializedName("lang")
|
||||||
private String lang = "en_US";
|
private String lang = "en_us";
|
||||||
@SerializedName("lang-options")
|
@SerializedName("lang-options")
|
||||||
private final String langOptions = "en_US, it_IT, pt_BR, tr_TR, zh_TW, zh_CH, de_DE";
|
private final String langOptions = "en_us, it_it, pt_br, tr_tr, zh_tw, zh_ch, de_de";
|
||||||
|
|
||||||
@SerializedName("keep-active")
|
@SerializedName("keep-active")
|
||||||
private Boolean keepActive = true;
|
private Boolean keepActive = true;
|
||||||
|
@ -276,6 +276,11 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
if (version >= 2.0 && version <= 2.1) {
|
if (version >= 2.0 && version <= 2.1) {
|
||||||
version = 2.2;
|
version = 2.2;
|
||||||
}
|
}
|
||||||
|
if (version == 2.2) {
|
||||||
|
// make sure that the lang is all lowercase
|
||||||
|
version = 2.3;
|
||||||
|
this.lang = this.lang.substring(0,3)+this.lang.substring(3).toLowerCase();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue